Android Open Source - SalesOrder S U P Settings Preferences Activity






From Project

Back to project page SalesOrder.

License

The source code is released under:

GNU General Public License

If you think the Android project SalesOrder 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.capgemini.SalesOrder.preferences;
//w  ww . j av  a2  s .  c om
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceChangeListener;
import android.widget.Toast;

import com.capgemini.SalesOrder.R;

/**
 * Settings screen for SUP in the preferences.
 */
public class SUPSettingsPreferencesActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener
{
  /**
   * preferences keys used inside application
   */
  public static final String SUP_PREF_SUP_HOST_KEY = "sup_pref_host";
  public static final String SUP_PREF_SUP_PORT_KEY = "sup_pref_port";
  public static final String SUP_PREF_APPLICATION_ID_KEY = "sup_pref_application_id";
  public static final String SUP_PREF_SECURITY_CONFIGURATION_KEY = "sup_pref_security_config";
  public static final String SUP_PREF_FARMID_KEY = "sup_pref_farmid";
  public static final String SUP_PREF_DOMAIN_KEY = "sup_pref_domain";
    public static final String SUP_PREF_URLSUFFIX_KEY = "sup_pref_urlsuffix";

  /**
   * preferences instances used inside the activity
   */
  private EditTextPreference supHostPreference;
  private EditTextPreference supPortPreference;
  private EditTextPreference supDomainPreference;
  private EditTextPreference applicationIDPreference;
  private EditTextPreference securityConfigPreference;
  private EditTextPreference farmIDPreference;
  private EditTextPreference supUrlSuffix;

  
  /** Called when the activity is first created. */
  @SuppressWarnings("deprecation")
  @Override
  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);

      addPreferencesFromResource(R.xml.sup_settings_preference_screen);
      supHostPreference = (EditTextPreference) getPreferenceScreen().findPreference(SUP_PREF_SUP_HOST_KEY);
      supPortPreference = (EditTextPreference) getPreferenceScreen().findPreference(SUP_PREF_SUP_PORT_KEY);
      supDomainPreference = (EditTextPreference) getPreferenceScreen().findPreference(SUP_PREF_DOMAIN_KEY);
      applicationIDPreference = (EditTextPreference) getPreferenceScreen().findPreference(SUP_PREF_APPLICATION_ID_KEY);
      securityConfigPreference = (EditTextPreference) getPreferenceScreen().findPreference(SUP_PREF_SECURITY_CONFIGURATION_KEY);  
      farmIDPreference = (EditTextPreference) getPreferenceScreen().findPreference(SUP_PREF_FARMID_KEY);
      supUrlSuffix = (EditTextPreference) getPreferenceScreen().findPreference(SUP_PREF_URLSUFFIX_KEY);
      
      supPortPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() 
      {
      public boolean onPreferenceChange(Preference preference,Object newValue) 
      {
        String newSUPPort = newValue.toString();
        try 
        {
          Integer.parseInt(newSUPPort);
        } 
        catch (NumberFormatException e) 
        {
          Toast.makeText(getBaseContext(), getString(R.string.validation_msg), Toast.LENGTH_LONG).show();
          return false;
        }
        
        return true;
      }
      });
  }
  
  @SuppressWarnings("deprecation")
  @Override
  protected void onResume() 
  {
    super.onResume();
      if (supHostPreference.getText() != null) 
      {
        supHostPreference.setSummary(supHostPreference.getText()); 
    }
    
      if (supPortPreference.getText() != null) 
      {
        supPortPreference.setSummary(supPortPreference.getText()); 
    }
    
    if (supDomainPreference.getText() != null)
      {
          supDomainPreference.setSummary(supDomainPreference.getText());
      }
    
      if (applicationIDPreference.getText() != null) 
      {
        applicationIDPreference.setSummary(applicationIDPreference.getText()); 
    }
    
      if (securityConfigPreference.getText() != null) 
      {
        securityConfigPreference.setSummary(securityConfigPreference.getText()); 
    }
    
      if (farmIDPreference.getText() != null) 
      {
        farmIDPreference.setSummary(farmIDPreference.getText()); 
    }
    
    if (supUrlSuffix.getText() != null)
      {
          supUrlSuffix.setSummary(supUrlSuffix.getText());
      }
      
    getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
  }

  @SuppressWarnings("deprecation")
  @Override
  protected void onPause() 
  {
    getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
    super.onPause();
    
    PreferenceState preferenceState = new PreferenceState(getApplicationContext());
    if (!preferenceState.checkRequiredSUPSettings())
    {
      Toast.makeText(getBaseContext(), getString(R.string.sup_validation_msg), Toast.LENGTH_LONG).show();
    }
  }

  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
      String key)
  {
    if (key.equalsIgnoreCase(SUP_PREF_SUP_HOST_KEY)) 
    {
      supHostPreference.setText(supHostPreference.getText().trim());
        supHostPreference.setSummary(supHostPreference.getText()); 
    }
    
    if (key.equalsIgnoreCase(SUP_PREF_SUP_PORT_KEY)) 
    {
      supPortPreference.setText(supPortPreference.getText().trim());
        supPortPreference.setSummary(supPortPreference.getText()); 
    }
    
    if (key.equalsIgnoreCase(SUP_PREF_DOMAIN_KEY)) 
      {
        supDomainPreference.setText(supDomainPreference.getText().trim());
        supDomainPreference.setSummary(supDomainPreference.getText()); 
      }
    
    if (key.equalsIgnoreCase(SUP_PREF_APPLICATION_ID_KEY)) 
    {
      applicationIDPreference.setText(applicationIDPreference.getText().trim());
        applicationIDPreference.setSummary(applicationIDPreference.getText()); 
    }
    
    if (key.equalsIgnoreCase(SUP_PREF_SECURITY_CONFIGURATION_KEY)) 
    {
      securityConfigPreference.setText(securityConfigPreference.getText().trim());
        securityConfigPreference.setSummary(securityConfigPreference.getText()); 
    }
    
    if (key.equalsIgnoreCase(SUP_PREF_FARMID_KEY)) 
    {
      farmIDPreference.setText(farmIDPreference.getText().trim());
        farmIDPreference.setSummary(farmIDPreference.getText()); 
    }
    
    if (key.equalsIgnoreCase(SUP_PREF_URLSUFFIX_KEY)) 
      {
        supUrlSuffix.setText(supUrlSuffix.getText().trim());
        supUrlSuffix.setSummary(supUrlSuffix.getText()); 
      }
  }
}




Java Source Code List

com.capgemini.SalesOrder.LoginActivity.java
com.capgemini.SalesOrder.Page1ListActivity.java
com.capgemini.SalesOrder.Page1ListAdapter.java
com.capgemini.SalesOrder.Page2ListActivity.java
com.capgemini.SalesOrder.Page2ListAdapter.java
com.capgemini.SalesOrder.Page3ListActivity.java
com.capgemini.SalesOrder.Page3ListAdapter.java
com.capgemini.SalesOrder.Page4DetailsActivity.java
com.capgemini.SalesOrder.Page4DetailsAdapter.java
com.capgemini.SalesOrder.Page5DetailsActivity.java
com.capgemini.SalesOrder.Page5DetailsAdapter.java
com.capgemini.SalesOrder.Page6DetailsActivity.java
com.capgemini.SalesOrder.Page6DetailsAdapter.java
com.capgemini.SalesOrder.SplashScreen.java
com.capgemini.SalesOrder.preferences.GatewaySettingsPreferencesActivity.java
com.capgemini.SalesOrder.preferences.MainPreferencesActivity.java
com.capgemini.SalesOrder.preferences.PreferencesUtilities.java
com.capgemini.SalesOrder.preferences.SUPSettingsPreferencesActivity.java
com.capgemini.SalesOrder.zgwsample_srv.ServiceVersionConfigurations.java
com.capgemini.SalesOrder.zgwsample_srv.v0.ZGWSAMPLE_SRVRequestHandler.java
com.capgemini.SalesOrder.zgwsample_srv.v0.ZGWSAMPLE_SRVService.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.BusinessPartner.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.Contact.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.Product.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.SalesOrderLineItem.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.SalesOrder.java
com.capgemini.SalesOrder.zgwsample_srv.v0.helpers.IZGWSAMPLE_SRVRequestHandlerListener.java
com.capgemini.SalesOrder.zgwsample_srv.v0.helpers.ListenerWrapper.java
com.capgemini.SalesOrder.zgwsample_srv.v0.helpers.ZGWSAMPLE_SRVLoginAsyncTask.java
com.capgemini.SalesOrder.zgwsample_srv.v0.helpers.ZGWSAMPLE_SRVRequestID.java