package com.rcarrillocruz.android.openstackdroid;

import android.app.ListActivity;
import android.widget.ArrayAdapter;
import android.os.Bundle;
import android.view.Menu;

public class LoginActivity extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        ConnectionProfile[] profiles = { 
        		new ConnectionProfile("admin on Testing cloud", "admin", "opsware", "1","http://192.168.1.20:5000"+"/v2.0/tokens"),
        		new ConnectionProfile("devops on Production", "devops", "lol", "2", "http://192.168.1.20:5000"+"/v2.0/tokens")
        };		
        
        
        ArrayAdapter<ConnectionProfile> adapter = new ArrayAdapter<ConnectionProfile>(this, android.R.layout.simple_list_item_1, profiles);
        
        setListAdapter(adapter);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}

@@ -44,16 +44,68 @@
 droid;%0A%0A
+import android.net.Uri;%0Aimport android.os.Handler;%0A%0A
 import a
@@ -129,16 +129,47 @@
 tivity;%0A
+import android.content.Intent;%0A
 import a
@@ -215,96 +215,372 @@
 oid.
-os.Bundle;%0Aimport android.view.Menu;%0A%0Apublic class LoginActivity extends ListActivity %7B%0A
+widget.ListView;%0Aimport android.widget.Toast;%0Aimport android.os.Bundle;%0Aimport android.view.Menu;%0Aimport android.view.View;%0A%0Aimport com.google.gson.Gson;%0Aimport com.rcarrillocruz.android.openstackdroid.CloudControllerResultReceiver.Receiver;%0A%0Apublic class LoginActivity extends ListActivity implements Receiver %7B%0A%09private CloudControllerResultReceiver mReceiver;%0A%09
 %0A   
@@ -743,33 +743,32 @@
 s = %7B %0A        %09
-%09
 new ConnectionPr
@@ -803,32 +803,8 @@
 d%22, 
-%22admin%22, %22opsware%22, %221%22,
 %22htt
@@ -825,30 +825,73 @@
 20:5000%22
-+%22/v2.0/tokens
+, %22admin%22, %22openstack%22, %22793e8386d75f47b1bd078a3c0ddd9a49
 %22),%0A    
@@ -895,17 +895,16 @@
        %09
-%09
 new Conn
@@ -944,30 +944,8 @@
 on%22,
- %22devops%22, %22lol%22, %222%22,
  %22ht
@@ -971,22 +971,29 @@
 000%22
-+%22/v2.0/tokens
+, %22devops%22, %22lol%22, %222
 %22)%0A 
@@ -1013,25 +1013,16 @@
        %0A
-        %0A
         
@@ -1153,25 +1153,16 @@
 files);%0A
-        %0A
         
@@ -1186,16 +1186,132 @@
 apter);%0A
+        %0A        mReceiver = new CloudControllerResultReceiver(new Handler());%0A        mReceiver.setReceiver(this);%0A
     %7D%0A%0A%0A
@@ -1543,10 +1543,1112 @@
  %7D%0A    %0A
+    protected void onListItemClick(ListView l, View v, int position, long id) %7B%0A        ConnectionProfile profileClicked = (ConnectionProfile) getListAdapter().getItem(position);%0A        %0A        Intent intent = new Intent(this, CloudControllerService.class);%0A        intent.setData(Uri.parse(%22http://192.168.1.20:5000%22));%0A        intent.putExtra(CloudControllerService.OPERATION, CloudControllerService.GET_TOKEN_OPERATION);%0A        intent.putExtra(CloudControllerService.RECEIVER, mReceiver);%0A        %0A        Bundle params = new Bundle();%0A        params.putString(%22username%22, profileClicked.getUsername());%0A        params.putString(%22password%22, profileClicked.getPassword());%0A        params.putString(%22tenantId%22, profileClicked.getTenantId());%0A        %0A        intent.putExtra(CloudControllerService.PARAMS, params);%0A        %0A        startService(intent);%0A    %7D%0A%0A%0A%09@Override%0A%09public void onReceiveResult(int resultCode, Bundle resultData) %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09if (resultCode == 200) %7B%0A%09%09%09Toast.makeText(this, resultData.getString(%22results%22),Toast.LENGTH_LONG).show();%0A%09%09%7D%0A%09%7D%0A    %0A
 %7D%0A

Add methods to test out connection profiles and interface with CloudControllerService