Android Open Source - Aether-s-Notebook-Android-Client Configuration Activity






From Project

Back to project page Aether-s-Notebook-Android-Client.

License

The source code is released under:

GNU General Public License

If you think the Android project Aether-s-Notebook-Android-Client 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 aethers.notebook.appender.managed.uploader;
/*from ww  w  .j a  v  a  2s  .c  o m*/
import java.io.File;
import java.util.ArrayList;

import aethers.notebook.R;
import aethers.notebook.appender.managed.uploader.Configuration.ConnectionType;
import aethers.notebook.core.ui.IntegerPreferenceChangeListener;
import aethers.notebook.core.ui.filechooser.DirectoryChooser;
import android.content.Intent;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;

public class ConfigurationActivity 
extends PreferenceActivity
{
    private static final int REQUEST_CODE = 111;
    
    private static final String EXTRA_RESULT = "DIRNAME";
    
    private Configuration configuration;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        configuration = new Configuration(this);
        getPreferenceManager().setSharedPreferencesName(Configuration.SHARED_PREFERENCES_NAME);
        addPreferencesFromResource(R.xml.uploaderappender);
        
        ListPreference connTypes = (ListPreference)findPreference(
                getString(R.string.UploaderAppender_Preferences_connectionType));
        ArrayList<String> entries = new ArrayList<String>();
        ArrayList<String> values = new ArrayList<String>();
        for(ConnectionType ct : ConnectionType.values())
        {
            entries.add(ct.friendlyName);
            values.add(ct.toString());
        }
        connTypes.setEntries(entries.toArray(new String[0]));
        connTypes.setEntryValues(values.toArray(new String[0]));
        
        Preference maxSize = 
                findPreference(getString(R.string.UploaderAppender_Preferences_maxFileSize));
        maxSize.setOnPreferenceChangeListener(new IntegerPreferenceChangeListener(
                1, Integer.MAX_VALUE, 
                "Maximum must be a number greater than or equal to 1", this));
        
        Preference maxFiles = 
            findPreference(getString(R.string.UploaderAppender_Preferences_maxFiles));
        maxFiles.setOnPreferenceChangeListener(
                new IntegerPreferenceChangeListener(
                        1, Integer.MAX_VALUE,
                        "Leave blank for unlimited, otherwise must be a number greater than 1",
                        true,
                        this));
        
        Preference dirPreference = findPreference(getString(R.string.UploaderAppender_Preferences_logDirectory));
        dirPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
        {
            @Override
            public boolean onPreferenceClick(Preference preference) 
            {
                Intent i = DirectoryChooser.createStartIntent(
                        ConfigurationActivity.this,
                        configuration.getLogDirectory().getAbsolutePath(),
                        EXTRA_RESULT);
                startActivityForResult(i, REQUEST_CODE);
                return true;
            }
        });
    }
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    {
        if(resultCode == RESULT_CANCELED)
            return;
        if(REQUEST_CODE != requestCode)
            return;
        if(data == null || !data.hasExtra(EXTRA_RESULT))
            return;
        String dir = data.getStringExtra(EXTRA_RESULT);
        configuration.setLogDirectory(new File(dir));
    }
}




Java Source Code List

aethers.notebook.appender.managed.file.ConfigurationActivity.java
aethers.notebook.appender.managed.file.Configuration.java
aethers.notebook.appender.managed.file.FileAppender.java
aethers.notebook.appender.managed.uploader.ConfigurationActivity.java
aethers.notebook.appender.managed.uploader.Configuration.java
aethers.notebook.appender.managed.uploader.UploaderAppender.java
aethers.notebook.core.Action.java
aethers.notebook.core.AppenderServiceIdentifier.java
aethers.notebook.core.BootReceiver.java
aethers.notebook.core.ConfigurationTemplate.java
aethers.notebook.core.Configuration.java
aethers.notebook.core.CoreService.java
aethers.notebook.core.LoggerServiceIdentifier.java
aethers.notebook.core.TimeStamp.java
aethers.notebook.core.ui.ConfigurationActivity.java
aethers.notebook.core.ui.EditIntegerPreference.java
aethers.notebook.core.ui.IntegerPreferenceChangeListener.java
aethers.notebook.core.ui.NonPersistingButtonPreference.java
aethers.notebook.core.ui.PersistingButtonPreference.java
aethers.notebook.core.ui.filechooser.DirectoryChooser.java
aethers.notebook.core.ui.filechooser.FileChooser.java
aethers.notebook.core.ui.filechooser.FileListAdapter.java
aethers.notebook.logger.managed.PushLogger.java
aethers.notebook.logger.managed.celllocation.CellLocationLogger.java
aethers.notebook.logger.managed.dataconnectionstate.DataConnectionStateLogger.java
aethers.notebook.logger.managed.position.ConfigurationActivity.java
aethers.notebook.logger.managed.position.Configuration.java
aethers.notebook.logger.managed.position.PositionLogger.java
aethers.notebook.logger.managed.servicestate.ServiceStateLogger.java
aethers.notebook.logger.managed.signalstrength.SignalStrengthLogger.java
aethers.notebook.logger.managed.wifi.ConfigurationActivity.java
aethers.notebook.logger.managed.wifi.Configuration.java
aethers.notebook.logger.managed.wifi.WifiLogger.java
aethers.notebook.util.Logger.java