Search in sources :

Example 1 with Preferences

use of com.openmeap.thinclient.Preferences in project OpenMEAP by OpenMEAP.

the class MainActivity method onCreate.

/**
	 * Called when the activity is first created.
	 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get rid of the android title bar
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);
    CredentialsProviderFactory.setDefaultCredentialsProviderFactory(new OmSlicCredentialsProvider.Factory(this));
    HttpRequestExecuterFactory.setDefaultType(HttpRequestExecuterImpl.class);
    DigestInputStreamFactory.setDigestInputStreamForName("md5", Md5DigestInputStream.class);
    DigestInputStreamFactory.setDigestInputStreamForName("sha1", Sha1DigestInputStream.class);
    // setup the SLICConfig instance
    Preferences prefs = new SharedPreferencesImpl(getSharedPreferences(SLICConfig.PREFERENCES_FILE, MODE_PRIVATE));
    try {
        Properties props = new Properties();
        props.load(getAssets().open(SLICConfig.PROPERTIES_FILE));
        config = new AndroidSLICConfig(this, prefs, props);
    } catch (IOException ioe) {
        // then the application is fail
        throw new RuntimeException("The primary configuration file (" + SLICConfig.PROPERTIES_FILE + ") could not be opened.");
    }
    // perform our first-run-check
    Object o = getSystemService(Context.WIFI_SERVICE);
    if (o instanceof WifiManager) {
        WifiManager wifiManager = (WifiManager) o;
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        if (wifiInfo != null && wifiInfo.getMacAddress() != null) {
            Runnable firstRunCheck = new FirstRunCheck(config, wifiInfo.getMacAddress(), HttpRequestExecuterFactory.newDefault());
            new Thread(firstRunCheck).start();
        }
    }
    if (config.isDevelopmentMode()) {
        System.setProperty(HttpRequestExecuter.SSL_PEER_NOVERIFY_PROPERTY, "true");
    } else {
        System.setProperty(HttpRequestExecuter.SSL_PEER_NOVERIFY_PROPERTY, "false");
    }
    storage = new LocalStorageImpl(this);
    updateHandler = new UpdateHandler(this, config, storage);
// Calls the title from client.properties
// setupWindowTitle();
}
Also used : WifiManager(android.net.wifi.WifiManager) UpdateHandler(com.openmeap.thinclient.update.UpdateHandler) IOException(java.io.IOException) Properties(java.util.Properties) WifiInfo(android.net.wifi.WifiInfo) FirstRunCheck(com.openmeap.thinclient.FirstRunCheck) Preferences(com.openmeap.thinclient.Preferences)

Aggregations

WifiInfo (android.net.wifi.WifiInfo)1 WifiManager (android.net.wifi.WifiManager)1 FirstRunCheck (com.openmeap.thinclient.FirstRunCheck)1 Preferences (com.openmeap.thinclient.Preferences)1 UpdateHandler (com.openmeap.thinclient.update.UpdateHandler)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1