Android Open Source - luminous Setup Activity






From Project

Back to project page luminous.

License

The source code is released under:

GNU General Public License

If you think the Android project luminous 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 de.denisulmer.luminous.v2;
/* w w w.j  av  a 2 s . c  o m*/
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.text.Editable;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
import android.widget.EditText;
import android.widget.Toast;

public class SetupActivity extends ActionBarActivity
{
    EditText mEditTextHostname;
    EditText mEditTextPort;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setupactivity_layout);

        // Set link in core
        Core.setSetupActivity(this);

        // Set EditTexts
        mEditTextHostname = (EditText) findViewById(R.id.setupactivity_host);
        mEditTextPort = (EditText) findViewById(R.id.setupactivity_port);

        // Fill out form if there is saved data
        if (Core.getSavedHostname().length() > 0)
        {
            mEditTextHostname.setText((CharSequence) Core.getSavedHostname());
        }
        if (Core.getSavedPort() > 0)
        {
            mEditTextPort.setText((CharSequence) Integer.toString(Core.getSavedPort()));
        }
    }


    public void onButtonClick(View view)
    {
        Editable enteredHostname = mEditTextHostname.getText();
        Editable enteredPort = mEditTextPort.getText();

        // Check if fields are filled
        if (enteredHostname.length() == 0 || enteredPort.length() == 0)
        {
            // Toast about filling out all required fields
            Toast.makeText(getBaseContext(), getString(R.string.setupactivity_filloutfields), Toast.LENGTH_SHORT).show();
        }
        else
        {
            // Save entered values for auto connect
            Core.setSavedHostname(enteredHostname.toString());
            Core.setSavedPort(Integer.parseInt(enteredPort.toString()));

            // Go back to the MainActivity
            Core.startMainActivity();
            finish();
        }
    }
}




Java Source Code List

de.denisulmer.luminous.v2.BackgroundTask.java
de.denisulmer.luminous.v2.Core.java
de.denisulmer.luminous.v2.DeviceListAdapter.java
de.denisulmer.luminous.v2.Device.java
de.denisulmer.luminous.v2.LocationFragment.java
de.denisulmer.luminous.v2.LocationPageAdapter.java
de.denisulmer.luminous.v2.MainActivity.java
de.denisulmer.luminous.v2.SetupActivity.java