Android Open Source - valence Selection Activity






From Project

Back to project page valence.

License

The source code is released under:

Apache License

If you think the Android project valence 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

/*
 * Copyright 2011 David Simmons//  ww w. j a  va2s . c om
 * http://cafbit.com/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cafbit.valence;

import android.content.Intent;
import android.net.Uri;
import android.view.Menu;
import android.view.MenuItem;

import com.cafbit.motelib.model.Device;
import com.cafbit.motelib.settings.AddDeviceActivity;
import com.cafbit.motelib.settings.DevicesActivity;
import com.cafbit.valence.device.ValenceDevice;

public class SelectionActivity extends DevicesActivity {

    // test code for short-circuiting the device selection menu.
    /*
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, ValenceActivity.class);
        intent.setAction(Intent.ACTION_VIEW);
        Uri.Builder builder = new Uri.Builder()
            .scheme("valence")
            .encodedAuthority(Uri.encode("demo.local")+":"+Uri.encode("5900"));
        Uri uri = builder.build();
        uri.getPort();
        //System.out.println("URI: "+uri);
        intent.setData(uri);
        startActivity(intent);

    }
    */

    protected void onDeviceSelected(Device d) {
        if (! (d instanceof ValenceDevice)) {
            return;
        }
        ValenceDevice device = (ValenceDevice)d;

        Intent intent = new Intent(this, ValenceActivity.class);
        intent.setAction(Intent.ACTION_VIEW);
        Uri.Builder builder = new Uri.Builder()
            .scheme("valence")
            .encodedAuthority(Uri.encode(device.address)+":"+Uri.encode(""+device.port));
        if ((device.password != null) && (device.password.length() > 0)) {
            builder.appendQueryParameter("password", device.password);
        }
        if (device.ard35Compatibility) {
            builder.appendQueryParameter("ard35Compatibility", "true");
        }
        if (device.macAuthentication) {
            builder.appendQueryParameter("macAuthentication", "true");
        }
        if ((device.username != null) && (device.username.length() > 0)) {
            builder.appendQueryParameter("username", device.username);
        }
        Uri uri = builder.build();
        uri.getPort();
        intent.setData(uri);
        startActivity(intent);
    }

    protected void onAddNewDevice() {
        Intent intent = new Intent(this, AddDeviceActivity.class);
        intent.putExtra("device_class", "valence");
        startActivity(intent);
    }

    //////////////////////////////////////////////////////////////////////
    // options menu
    //////////////////////////////////////////////////////////////////////

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        return OptionsMenuHelper.onCreateOptionsMenu(this, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        boolean result = OptionsMenuHelper.onOptionsItemSelected(this, item);
        if (result) {
            return true;
        } else {
            return super.onOptionsItemSelected(item);
        }
    }


}




Java Source Code List

com.cafbit.valence.HelpActivity.java
com.cafbit.valence.MoteContextImpl.java
com.cafbit.valence.OptionsMenuHelper.java
com.cafbit.valence.RFBRecvThread.java
com.cafbit.valence.RFBThread.java
com.cafbit.valence.SelectionActivity.java
com.cafbit.valence.TouchPadEvent.java
com.cafbit.valence.TouchPadHandler.java
com.cafbit.valence.TouchPadView.java
com.cafbit.valence.ValenceActivity.java
com.cafbit.valence.ValenceApplication.java
com.cafbit.valence.ValenceIOException.java
com.cafbit.valence.device.ValenceDeviceClass.java
com.cafbit.valence.device.ValenceDeviceSetupView.java
com.cafbit.valence.device.ValenceDevice.java
com.cafbit.valence.device.ValenceMDNSDiscoveryHandler.java
com.cafbit.valence.rfb.DES.java
com.cafbit.valence.rfb.KeyTranslator.java
com.cafbit.valence.rfb.RFBConnection.java
com.cafbit.valence.rfb.RFBEvent.java
com.cafbit.valence.rfb.RFBException.java
com.cafbit.valence.rfb.RFBKeyEvent.java
com.cafbit.valence.rfb.RFBMessage.java
com.cafbit.valence.rfb.RFBPointerEvent.java
com.cafbit.valence.rfb.RFBSecurityARD.java
com.cafbit.valence.rfb.RFBSecurityNone.java
com.cafbit.valence.rfb.RFBSecurityVNC.java
com.cafbit.valence.rfb.RFBSecurity.java
com.cafbit.valence.rfb.RFBStream.java
com.cafbit.valence.rfb.Security.java
com.cafbit.valence.rfb.Util.java
com.cafbit.valence.rfb.Version.java