Revision 639ae8d6
b/AndroidManifest.xml | ||
---|---|---|
144 | 144 |
android:theme="@android:style/Theme.Dialog"></activity> |
145 | 145 |
<activity android:name=".AddLoadBalancerActivity" |
146 | 146 |
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity> |
147 |
<activity android:name=".AddNodesActivity"></activity> |
|
147 | 148 |
|
148 | 149 |
|
149 | 150 |
|
b/res/layout/addnodes.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:orientation="vertical" android:layout_width="fill_parent" |
|
4 |
android:layout_height="fill_parent" android:background="@drawable/rack_bg_transparent"> |
|
5 |
<ImageView android:id="@+id/headerimage" |
|
6 |
android:layout_width="wrap_content" android:layout_height="80dip"></ImageView> |
|
7 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
8 |
android:layout_width="fill_parent" android:layout_height="fill_parent"> |
|
9 |
<ListView android:id="@+id/android:list" |
|
10 |
android:layout_width="fill_parent" android:cacheColorHint="@android:color/transparent" |
|
11 |
android:layout_height="417dp" /> |
|
12 |
</LinearLayout> |
|
13 |
<ImageView android:id="@+id/headerimage" |
|
14 |
android:layout_width="wrap_content" android:layout_height="25dip"></ImageView> |
|
15 |
</LinearLayout> |
|
16 |
|
|
17 |
|
b/res/layout/list_loadbalancers.xml | ||
---|---|---|
5 | 5 |
<ImageView android:id="@+id/headerimage" |
6 | 6 |
android:layout_width="wrap_content" android:layout_height="80dip"></ImageView> |
7 | 7 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
8 |
android:orientation="vertical" android:layout_width="fill_parent" |
|
9 |
android:layout_height="fill_parent"> |
|
8 |
android:orientation="vertical" android:layout_width="fill_parent"
|
|
9 |
android:layout_height="fill_parent">
|
|
10 | 10 |
<ListView android:id="@+id/android:list" |
11 | 11 |
android:layout_width="fill_parent" android:layout_height="fill_parent" |
12 | 12 |
android:cacheColorHint="@android:color/transparent" /> |
b/res/layout/listservernodecell.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:orientation="horizontal" |
|
4 |
android:layout_width="fill_parent" |
|
5 |
android:layout_height="64dip" |
|
6 |
> |
|
7 |
<ImageView android:id="@+id/icon" |
|
8 |
android:layout_width="37px" |
|
9 |
android:paddingLeft="0px" |
|
10 |
android:paddingRight="0px" |
|
11 |
android:paddingTop="0px" |
|
12 |
android:layout_marginRight="10px" |
|
13 |
android:layout_marginLeft="10px" |
|
14 |
android:layout_marginTop="13px" |
|
15 |
android:layout_height="37px" |
|
16 |
android:src="@drawable/ubuntu_icon" /> |
|
17 |
|
|
18 |
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
19 |
android:orientation="vertical" |
|
20 |
android:layout_width="fill_parent" |
|
21 |
android:layout_height="fill_parent"> |
|
22 |
|
|
23 |
<TableRow> |
|
24 |
<TextView android:id="@+id/label" |
|
25 |
android:layout_width="wrap_content" |
|
26 |
android:layout_height="wrap_content" |
|
27 |
android:layout_marginTop="5px" |
|
28 |
android:textColor="#FFFFFF" |
|
29 |
android:textSize="24sp" /> |
|
30 |
<CheckBox android:id="@+id/checkBox1" android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent"></CheckBox> |
|
31 |
</TableRow> |
|
32 |
|
|
33 |
<TableRow> |
|
34 |
<TextView android:id="@+id/sublabel" |
|
35 |
android:layout_width="wrap_content" |
|
36 |
android:layout_height="wrap_content" |
|
37 |
android:layout_marginTop="0px" |
|
38 |
android:textColor="#FFFFFF" |
|
39 |
android:text="256 server - CentOS 5.3" |
|
40 |
android:textSize="12sp" /> |
|
41 |
</TableRow> |
|
42 |
</TableLayout> |
|
43 |
|
|
44 |
|
|
45 |
</LinearLayout> |
b/res/layout/view_add_loadbalancer.xml | ||
---|---|---|
8 | 8 |
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" |
9 | 9 |
android:layout_width="fill_parent" android:layout_height="fill_parent" |
10 | 10 |
android:layout_weight="1"> |
11 |
<TableLayout android:layout_height="wrap_content" android:background="@drawable/itemsbox" android:layout_width="fill_parent" android:paddingLeft="5dip" android:id="@+id/view_loadbalancer_layout" android:paddingBottom="30dip"> |
|
12 |
<TextView android:text="LoadBalancer" android:textSize="20.0sp" android:gravity="fill_horizontal" android:layout_marginLeft="22dip" android:layout_height="wrap_content" android:scrollHorizontally="true" android:textColor="#fff" android:layout_marginRight="30dip" android:layout_width="fill_parent" android:layout_marginTop="30dip" android:paddingTop="10dip" android:layout_marginBottom="10dip"></TextView> |
|
13 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/edit_lb_name_layout"> |
|
14 |
<TextView android:singleLine="false" android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" android:textColor="#333" android:textStyle="bold" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="5dip" android:text="Name"></TextView> |
|
15 |
<EditText android:layout_weight="1" android:layout_marginRight="20dip" android:id="@+id/edit_lb_name_text" android:layout_height="wrap_content" android:layout_width="wrap_content"> |
|
11 |
<TableLayout android:layout_height="wrap_content" |
|
12 |
android:background="@drawable/itemsbox" android:layout_width="fill_parent" |
|
13 |
android:paddingLeft="5dip" android:id="@+id/view_loadbalancer_layout" |
|
14 |
android:paddingBottom="30dip"> |
|
15 |
<TextView android:text="LoadBalancer" android:textSize="20.0sp" |
|
16 |
android:gravity="fill_horizontal" android:layout_marginLeft="22dip" |
|
17 |
android:layout_height="wrap_content" android:scrollHorizontally="true" |
|
18 |
android:textColor="#fff" android:layout_marginRight="30dip" |
|
19 |
android:layout_width="fill_parent" android:layout_marginTop="30dip" |
|
20 |
android:paddingTop="10dip" android:layout_marginBottom="10dip"></TextView> |
|
21 |
<TableRow android:orientation="horizontal" |
|
22 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
|
23 |
android:id="@+id/edit_lb_name_layout"> |
|
24 |
<TextView android:singleLine="false" |
|
25 |
android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" |
|
26 |
android:textColor="#333" android:textStyle="bold" |
|
27 |
android:layout_height="wrap_content" android:layout_width="wrap_content" |
|
28 |
android:paddingLeft="5dip" android:text="Name"></TextView> |
|
29 |
<EditText android:layout_weight="1" |
|
30 |
android:layout_marginRight="20dip" android:layout_height="wrap_content" |
|
31 |
android:layout_width="wrap_content" android:id="@+id/edit_lb_name_text"> |
|
16 | 32 |
<requestFocus></requestFocus> |
17 | 33 |
</EditText> |
18 | 34 |
</TableRow> |
19 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/edit_protocol_layout"> |
|
20 |
<TextView android:singleLine="false" android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" android:textColor="#333" android:textStyle="bold" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="5dip" android:text="Protocol"></TextView> |
|
21 |
<Spinner android:id="@+id/edit_protocol_spinner" android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="wrap_content" android:layout_marginRight="20dip"></Spinner> |
|
35 |
<TableRow android:orientation="horizontal" |
|
36 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
|
37 |
android:id="@+id/edit_protocol_layout"> |
|
38 |
<TextView android:singleLine="false" |
|
39 |
android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" |
|
40 |
android:textColor="#333" android:textStyle="bold" |
|
41 |
android:layout_height="wrap_content" android:layout_width="wrap_content" |
|
42 |
android:paddingLeft="5dip" android:text="Protocol"></TextView> |
|
43 |
<Spinner android:id="@+id/edit_protocol_spinner" |
|
44 |
android:layout_height="wrap_content" android:layout_weight="1" |
|
45 |
android:layout_width="wrap_content" android:layout_marginRight="20dip"></Spinner> |
|
22 | 46 |
</TableRow> |
23 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/edit_port_layout"> |
|
24 |
<TextView android:singleLine="false" android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" android:textColor="#333" android:textStyle="bold" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="5dip" android:text="Port"></TextView> |
|
25 |
<EditText android:layout_weight="1" android:layout_marginRight="20dip" android:id="@+id/edit_port_text" android:layout_height="wrap_content" android:layout_width="wrap_content"></EditText> |
|
47 |
<TableRow android:orientation="horizontal" |
|
48 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
|
49 |
android:id="@+id/edit_port_layout"> |
|
50 |
<TextView android:singleLine="false" |
|
51 |
android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" |
|
52 |
android:textColor="#333" android:textStyle="bold" |
|
53 |
android:layout_height="wrap_content" android:layout_width="wrap_content" |
|
54 |
android:paddingLeft="5dip" android:text="Port"></TextView> |
|
55 |
<EditText android:inputType="number" android:layout_height="wrap_content" |
|
56 |
android:id="@+id/edit_port_text" android:layout_width="fill_parent" |
|
57 |
android:layout_marginRight="20dip" android:layout_weight="1"></EditText> |
|
26 | 58 |
</TableRow> |
27 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/edit_vip_layout"> |
|
28 |
<TextView android:text="@string/virtual_ip_type" android:singleLine="false" android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" android:textColor="#333" android:textStyle="bold" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="5dip"></TextView> |
|
29 |
<Spinner android:id="@+id/edit_vip_spinner" android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="wrap_content" android:layout_marginRight="20dip"></Spinner> |
|
59 |
<TableRow android:orientation="horizontal" |
|
60 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
|
61 |
android:id="@+id/edit_vip_layout"> |
|
62 |
<TextView android:text="@string/virtual_ip_type" |
|
63 |
android:singleLine="false" android:layout_gravity="center_vertical" |
|
64 |
android:layout_marginLeft="22dip" android:textColor="#333" |
|
65 |
android:textStyle="bold" android:layout_height="wrap_content" |
|
66 |
android:layout_width="wrap_content" android:paddingLeft="5dip"></TextView> |
|
67 |
<Spinner android:id="@+id/edit_vip_spinner" |
|
68 |
android:layout_height="wrap_content" android:layout_weight="1" |
|
69 |
android:layout_width="wrap_content" android:layout_marginRight="20dip"></Spinner> |
|
30 | 70 |
</TableRow> |
31 |
<TableRow android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/edit_algorithm_layout"> |
|
32 |
<TextView android:text="Algorithm" android:singleLine="false" android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" android:textColor="#333" android:textStyle="bold" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="5dip"></TextView> |
|
33 |
<Spinner android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="wrap_content" android:layout_marginRight="20dip" android:id="@+id/edit_algorithm_spinner"></Spinner> |
|
71 |
<TableRow android:orientation="horizontal" |
|
72 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
|
73 |
android:id="@+id/edit_algorithm_layout"> |
|
74 |
<TextView android:text="Algorithm" android:singleLine="false" |
|
75 |
android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" |
|
76 |
android:textColor="#333" android:textStyle="bold" |
|
77 |
android:layout_height="wrap_content" android:layout_width="wrap_content" |
|
78 |
android:paddingLeft="5dip"></TextView> |
|
79 |
<Spinner android:layout_height="wrap_content" |
|
80 |
android:layout_weight="1" android:layout_width="wrap_content" |
|
81 |
android:layout_marginRight="20dip" android:id="@+id/edit_algorithm_spinner"></Spinner> |
|
34 | 82 |
</TableRow> |
35 |
<TableRow android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/edit_region_layout"> |
|
36 |
<TextView android:singleLine="false" android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" android:textColor="#333" android:textStyle="bold" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="5dip" android:text="Region"></TextView> |
|
37 |
<Spinner android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="wrap_content" android:layout_marginRight="20dip" android:id="@+id/edit_region_spinner"></Spinner> |
|
83 |
<TableRow android:orientation="horizontal" |
|
84 |
android:layout_width="fill_parent" android:layout_height="wrap_content" |
|
85 |
android:id="@+id/edit_region_layout"> |
|
86 |
<TextView android:singleLine="false" |
|
87 |
android:layout_gravity="center_vertical" android:layout_marginLeft="22dip" |
|
88 |
android:textColor="#333" android:textStyle="bold" |
|
89 |
android:layout_height="wrap_content" android:layout_width="wrap_content" |
|
90 |
android:paddingLeft="5dip" android:text="Region"></TextView> |
|
91 |
<Spinner android:layout_height="wrap_content" |
|
92 |
android:layout_weight="1" android:layout_width="wrap_content" |
|
93 |
android:layout_marginRight="20dip" android:id="@+id/edit_region_spinner"></Spinner> |
|
94 |
</TableRow> |
|
95 |
<TableRow android:layout_width="wrap_content" |
|
96 |
android:layout_height="wrap_content" android:id="@+id/add_nodes_layout" |
|
97 |
android:gravity="center"> |
|
98 |
<Button android:layout_height="wrap_content" android:id="@+id/add_nodes_button" |
|
99 |
android:layout_width="wrap_content" android:text="Add Nodes"></Button> |
|
38 | 100 |
</TableRow> |
39 | 101 |
</TableLayout> |
40 | 102 |
</ScrollView> |
b/src/com/rackspace/cloud/files/api/client/CustomHttpClient.java | ||
---|---|---|
1 | 1 |
package com.rackspace.cloud.files.api.client; |
2 | 2 |
|
3 | 3 |
import android.content.Context; |
4 |
|
|
5 |
import org.apache.http.HttpVersion; |
|
4 | 6 |
import org.apache.http.conn.ClientConnectionManager; |
5 | 7 |
import org.apache.http.conn.scheme.PlainSocketFactory; |
6 | 8 |
import org.apache.http.conn.scheme.Scheme; |
... | ... | |
8 | 10 |
import org.apache.http.conn.ssl.SSLSocketFactory; |
9 | 11 |
import org.apache.http.impl.client.DefaultHttpClient; |
10 | 12 |
import org.apache.http.impl.conn.SingleClientConnManager; |
13 |
import org.apache.http.params.BasicHttpParams; |
|
14 |
import org.apache.http.params.CoreProtocolPNames; |
|
15 |
import org.apache.http.params.HttpParams; |
|
11 | 16 |
|
12 | 17 |
import com.rackspacecloud.android.R; |
13 | 18 |
|
... | ... | |
26 | 31 |
public class CustomHttpClient extends DefaultHttpClient { |
27 | 32 |
|
28 | 33 |
final Context context; |
29 |
|
|
34 |
/* |
|
35 |
public CustomHttpClient(Context context, HttpParams params) { |
|
36 |
super(params); |
|
37 |
this.context = context; |
|
38 |
} |
|
39 |
*/ |
|
30 | 40 |
public CustomHttpClient(Context context) { |
41 |
super(); |
|
31 | 42 |
this.context = context; |
32 | 43 |
} |
33 |
|
|
44 |
|
|
34 | 45 |
@Override |
35 | 46 |
protected ClientConnectionManager createClientConnectionManager() { |
36 | 47 |
SchemeRegistry registry = new SchemeRegistry(); |
b/src/com/rackspacecloud/android/ActivityChooser.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import android.app.Activity; |
7 | 7 |
import android.app.ProgressDialog; |
8 |
import android.app.TabActivity; |
|
9 | 8 |
import android.content.Context; |
10 |
import android.content.DialogInterface; |
|
11 |
import android.content.DialogInterface.OnClickListener; |
|
12 | 9 |
import android.content.Intent; |
13 |
import android.util.Log; |
|
14 |
import android.view.Gravity; |
|
15 | 10 |
import android.view.View; |
16 | 11 |
import android.view.WindowManager; |
17 |
import android.view.ViewGroup.LayoutParams; |
|
18 |
import android.widget.ArrayAdapter; |
|
19 |
import android.widget.Button; |
|
20 | 12 |
import android.widget.ImageButton; |
21 |
import android.widget.LinearLayout; |
|
22 |
import android.widget.ListView; |
|
23 |
import android.widget.ProgressBar; |
|
24 |
import android.widget.TabHost; |
|
25 | 13 |
import android.os.Bundle; |
26 | 14 |
|
27 | 15 |
public class ActivityChooser extends Activity { |
b/src/com/rackspacecloud/android/AddLoadBalancerActivity.java | ||
---|---|---|
1 | 1 |
package com.rackspacecloud.android; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Arrays; |
|
5 |
import java.util.Iterator; |
|
6 |
|
|
7 | 3 |
import com.rackspace.cloud.loadbalancer.api.client.Algorithm; |
8 |
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancer; |
|
9 | 4 |
import com.rackspace.cloud.loadbalancer.api.client.Protocol; |
10 |
import com.rackspace.cloud.loadbalancer.api.client.ProtocolManager; |
|
11 |
import com.rackspace.cloud.servers.api.client.Image; |
|
12 | 5 |
|
13 | 6 |
import android.app.Activity; |
14 | 7 |
import android.app.AlertDialog; |
15 |
import android.content.Context; |
|
16 | 8 |
import android.content.DialogInterface; |
17 |
import android.os.AsyncTask;
|
|
9 |
import android.content.Intent;
|
|
18 | 10 |
import android.os.Bundle; |
19 |
import android.util.Log; |
|
20 | 11 |
import android.view.View; |
12 |
import android.view.View.OnClickListener; |
|
21 | 13 |
import android.widget.AdapterView; |
22 | 14 |
import android.widget.AdapterView.OnItemSelectedListener; |
23 | 15 |
import android.widget.ArrayAdapter; |
16 |
import android.widget.Button; |
|
24 | 17 |
import android.widget.EditText; |
25 | 18 |
import android.widget.Spinner; |
26 | 19 |
|
27 | 20 |
public class AddLoadBalancerActivity extends Activity implements OnItemSelectedListener { |
28 | 21 |
|
22 |
//TODO Shared Virtual IP (not in API though?) |
|
23 |
private static final String[] VIP_TYPES = {"Public", "ServiceNet"}; |
|
24 |
private static final String[] REGIONS = {"ORD", "DFW"}; |
|
25 |
|
|
29 | 26 |
private Protocol[] protocols; |
30 | 27 |
private Algorithm[] algorithms; |
31 |
private LoadBalancer loadBalancer; |
|
32 |
private Context context; |
|
33 | 28 |
private Spinner protocolSpinner; |
34 | 29 |
private Spinner algorithmSpinner; |
30 |
private Spinner vipSpinner; |
|
31 |
private Spinner regionSpinner; |
|
35 | 32 |
private EditText portText; |
36 | 33 |
private Protocol selectedProtocol; |
34 |
private Algorithm selectedAlgorithm; |
|
35 |
private String selectedVipType; |
|
36 |
private String selectedRegion; |
|
37 |
private String selectedName; |
|
38 |
private String selectedPort; |
|
37 | 39 |
|
38 | 40 |
@Override |
39 | 41 |
public void onCreate(Bundle savedInstanceState) { |
... | ... | |
43 | 45 |
} |
44 | 46 |
|
45 | 47 |
private void restoreState(Bundle state) { |
46 |
context = getApplicationContext(); |
|
47 | 48 |
portText = (EditText)findViewById(R.id.edit_port_text); |
48 | 49 |
loadProtocolSpinner(); |
49 | 50 |
loadAlgorithmSpinner(); |
51 |
loadVipSpinner(); |
|
52 |
loadRegionSpinner(); |
|
53 |
setUpButton(); |
|
50 | 54 |
} |
51 | 55 |
|
52 | 56 |
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
... | ... | |
54 | 58 |
selectedProtocol = protocols[position]; |
55 | 59 |
portText.setText(protocols[position].getPort()); |
56 | 60 |
} |
61 |
else if (parent == algorithmSpinner){ |
|
62 |
selectedAlgorithm = algorithms[position]; |
|
63 |
} |
|
64 |
else if (parent == vipSpinner){ |
|
65 |
selectedVipType = VIP_TYPES[position]; |
|
66 |
} |
|
67 |
else if (parent == regionSpinner){ |
|
68 |
selectedRegion = REGIONS[position]; |
|
69 |
} |
|
57 | 70 |
} |
58 | 71 |
|
59 | 72 |
public void onNothingSelected(AdapterView<?> parent) { |
60 | 73 |
|
61 | 74 |
} |
75 |
|
|
76 |
private void setUpButton(){ |
|
77 |
Button addNodes = (Button) findViewById(R.id.add_nodes_button); |
|
78 |
addNodes.setOnClickListener(new OnClickListener() { |
|
79 |
|
|
80 |
@Override |
|
81 |
public void onClick(View v) { |
|
82 |
selectedName = ((EditText)findViewById(R.id.edit_lb_name_text)).getText().toString(); |
|
83 |
selectedPort = ((EditText)findViewById(R.id.edit_port_text)).getText().toString(); |
|
84 |
if(!validName()){ |
|
85 |
showAlert("Error", "Load balancer name cannot be blank."); |
|
86 |
} |
|
87 |
else if(!validPort()){ |
|
88 |
showAlert("Error", "Must have a protocol port number that is between 1 and 65535."); |
|
89 |
} |
|
90 |
else{ |
|
91 |
Intent viewIntent = new Intent(getApplicationContext(), AddNodesActivity.class); |
|
92 |
viewIntent.putExtra("name", selectedName); |
|
93 |
viewIntent.putExtra("protocol", selectedProtocol); |
|
94 |
viewIntent.putExtra("port", selectedPort); |
|
95 |
viewIntent.putExtra("vip", selectedVipType); |
|
96 |
viewIntent.putExtra("algorithm", selectedAlgorithm); |
|
97 |
viewIntent.putExtra("region", selectedRegion); |
|
98 |
startActivity(viewIntent); |
|
99 |
} |
|
100 |
} |
|
101 |
}); |
|
102 |
} |
|
103 |
|
|
104 |
private boolean validName(){ |
|
105 |
return !selectedName.equals(""); |
|
106 |
} |
|
107 |
|
|
108 |
private boolean validPort(){ |
|
109 |
return !selectedPort.equals("") && Integer.valueOf(selectedPort) > 0 && Integer.valueOf(selectedPort) < 65536; |
|
110 |
} |
|
111 |
|
|
112 |
private void loadRegionSpinner() { |
|
113 |
regionSpinner = (Spinner) findViewById(R.id.edit_region_spinner); |
|
114 |
regionSpinner.setOnItemSelectedListener(this); |
|
115 |
|
|
116 |
ArrayAdapter<String> regionAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, REGIONS); |
|
117 |
regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
118 |
regionSpinner.setAdapter(regionAdapter); |
|
119 |
} |
|
120 |
|
|
121 |
private void loadVipSpinner() { |
|
122 |
vipSpinner = (Spinner) findViewById(R.id.edit_vip_spinner); |
|
123 |
vipSpinner.setOnItemSelectedListener(this); |
|
124 |
|
|
125 |
ArrayAdapter<String> vipAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, VIP_TYPES); |
|
126 |
vipAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
127 |
vipSpinner.setAdapter(vipAdapter); |
|
128 |
} |
|
62 | 129 |
|
63 | 130 |
private void loadProtocolSpinner() { |
64 | 131 |
protocolSpinner = (Spinner) findViewById(R.id.edit_protocol_spinner); |
b/src/com/rackspacecloud/android/AddNodesActivity.java | ||
---|---|---|
1 |
package com.rackspacecloud.android; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
|
6 |
import com.rackspace.cloud.servers.api.client.Server; |
|
7 |
import com.rackspace.cloud.servers.api.client.ServerManager; |
|
8 |
|
|
9 |
import android.app.AlertDialog; |
|
10 |
import android.app.ListActivity; |
|
11 |
import android.app.ProgressDialog; |
|
12 |
import android.content.Context; |
|
13 |
import android.content.DialogInterface; |
|
14 |
import android.os.AsyncTask; |
|
15 |
import android.os.Bundle; |
|
16 |
import android.view.LayoutInflater; |
|
17 |
import android.view.View; |
|
18 |
import android.view.ViewGroup; |
|
19 |
import android.view.WindowManager; |
|
20 |
import android.view.ViewGroup.LayoutParams; |
|
21 |
import android.widget.ArrayAdapter; |
|
22 |
import android.widget.ImageView; |
|
23 |
import android.widget.ProgressBar; |
|
24 |
import android.widget.TextView; |
|
25 |
|
|
26 |
public class AddNodesActivity extends ListActivity { |
|
27 |
|
|
28 |
private Server[] servers; |
|
29 |
private Context context; |
|
30 |
ProgressDialog pDialog; |
|
31 |
|
|
32 |
@Override |
|
33 |
public void onCreate(Bundle savedInstanceState) { |
|
34 |
super.onCreate(savedInstanceState); |
|
35 |
setContentView(R.layout.addnodes); |
|
36 |
restoreState(savedInstanceState); |
|
37 |
} |
|
38 |
|
|
39 |
private void restoreState(Bundle state) { |
|
40 |
context = getApplicationContext(); |
|
41 |
if (state != null && state.containsKey("server")) { |
|
42 |
servers = (Server[]) state.getSerializable("servers"); |
|
43 |
if (servers.length == 0) { |
|
44 |
displayNoServersCell(); |
|
45 |
} else { |
|
46 |
getListView().setDividerHeight(1); // restore divider lines |
|
47 |
setListAdapter(new ServerAdapter()); |
|
48 |
} |
|
49 |
} else { |
|
50 |
loadServers(); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
private void displayNoServersCell() { |
|
55 |
String a[] = new String[1]; |
|
56 |
a[0] = "No Servers"; |
|
57 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.noserverscell, R.id.no_servers_label, a)); |
|
58 |
getListView().setTextFilterEnabled(true); |
|
59 |
getListView().setDividerHeight(0); // hide the dividers so it won't look like a list row |
|
60 |
getListView().setItemsCanFocus(false); |
|
61 |
} |
|
62 |
|
|
63 |
private void setServerList(ArrayList<Server> servers) { |
|
64 |
if (servers == null) { |
|
65 |
servers = new ArrayList<Server>(); |
|
66 |
} |
|
67 |
String[] serverNames = new String[servers.size()]; |
|
68 |
this.servers = new Server[servers.size()]; |
|
69 |
|
|
70 |
if (servers != null) { |
|
71 |
for (int i = 0; i < servers.size(); i++) { |
|
72 |
Server server = servers.get(i); |
|
73 |
this.servers[i] = server; |
|
74 |
serverNames[i] = server.getName(); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
if (serverNames.length == 0) { |
|
79 |
displayNoServersCell(); |
|
80 |
} else { |
|
81 |
getListView().setDividerHeight(1); // restore divider lines |
|
82 |
setListAdapter(new ServerAdapter()); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
private void loadServers() { |
|
87 |
new LoadServersTask().execute((Void[]) null); |
|
88 |
} |
|
89 |
|
|
90 |
protected void showDialog() { |
|
91 |
pDialog = new ProgressDialog(this, R.style.NewDialog); |
|
92 |
// // Set blur to background |
|
93 |
WindowManager.LayoutParams lp = pDialog.getWindow().getAttributes(); |
|
94 |
lp.dimAmount = 0.0f; |
|
95 |
pDialog.getWindow().setAttributes(lp); |
|
96 |
pDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); |
|
97 |
pDialog.show(); |
|
98 |
pDialog.setContentView(new ProgressBar(this), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); |
|
99 |
} |
|
100 |
|
|
101 |
private void showAlert(String title, String message) { |
|
102 |
AlertDialog alert = new AlertDialog.Builder(this).create(); |
|
103 |
alert.setTitle(title); |
|
104 |
alert.setMessage(message); |
|
105 |
alert.setButton("OK", new DialogInterface.OnClickListener() { |
|
106 |
public void onClick(DialogInterface dialog, int which) { |
|
107 |
return; |
|
108 |
} }); |
|
109 |
alert.show(); |
|
110 |
} |
|
111 |
|
|
112 |
private class LoadServersTask extends AsyncTask<Void, Void, ArrayList<Server>> { |
|
113 |
private CloudServersException exception; |
|
114 |
|
|
115 |
@Override |
|
116 |
protected void onPreExecute(){ |
|
117 |
showDialog(); |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
protected ArrayList<Server> doInBackground(Void... arg0) { |
|
122 |
ArrayList<Server> servers = null; |
|
123 |
try { |
|
124 |
servers = (new ServerManager()).createList(true, context); |
|
125 |
} catch (CloudServersException e) { |
|
126 |
exception = e; |
|
127 |
} |
|
128 |
pDialog.dismiss(); |
|
129 |
return servers; |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
protected void onPostExecute(ArrayList<Server> result) { |
|
134 |
if (exception != null) { |
|
135 |
showAlert("Error", exception.getMessage()); |
|
136 |
} |
|
137 |
setServerList(result); |
|
138 |
} |
|
139 |
} |
|
140 |
|
|
141 |
// * Adapter/ |
|
142 |
class ServerAdapter extends ArrayAdapter<Server> { |
|
143 |
ServerAdapter() { |
|
144 |
super(AddNodesActivity.this, R.layout.listservernodecell, servers); |
|
145 |
} |
|
146 |
|
|
147 |
public View getView(int position, View convertView, ViewGroup parent) { |
|
148 |
|
|
149 |
Server server = servers[position]; |
|
150 |
LayoutInflater inflater = getLayoutInflater(); |
|
151 |
View row = inflater.inflate(R.layout.listservercell, parent, false); |
|
152 |
|
|
153 |
TextView label = (TextView) row.findViewById(R.id.label); |
|
154 |
label.setText(server.getName()); |
|
155 |
|
|
156 |
TextView sublabel = (TextView) row.findViewById(R.id.sublabel); |
|
157 |
sublabel.setText(server.getFlavor().getName() + " - " + server.getImage().getName()); |
|
158 |
|
|
159 |
ImageView icon = (ImageView) row.findViewById(R.id.icon); |
|
160 |
icon.setImageResource(server.getImage().iconResourceId()); |
|
161 |
|
|
162 |
return(row); |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
} |
b/src/com/rackspacecloud/android/AddServerActivity.java | ||
---|---|---|
11 | 11 |
import android.content.DialogInterface; |
12 | 12 |
import android.os.AsyncTask; |
13 | 13 |
import android.os.Bundle; |
14 |
import android.text.InputFilter; |
|
15 |
import android.text.Spanned; |
|
16 |
import android.util.Log; |
|
17 | 14 |
import android.view.View; |
18 | 15 |
import android.view.View.OnClickListener; |
19 | 16 |
import android.widget.AdapterView; |
b/src/com/rackspacecloud/android/ContainerObjectDetails.java | ||
---|---|---|
6 | 6 |
import java.io.FileOutputStream; |
7 | 7 |
import java.io.IOException; |
8 | 8 |
import java.io.StringReader; |
9 |
import java.text.ParseException; |
|
10 |
import java.text.SimpleDateFormat; |
|
11 |
import java.util.Date; |
|
12 | 9 |
|
13 | 10 |
import javax.xml.parsers.FactoryConfigurationError; |
14 | 11 |
import javax.xml.parsers.ParserConfigurationException; |
b/src/com/rackspacecloud/android/ListAccountsActivity.java | ||
---|---|---|
97 | 97 |
loggedIn = false; |
98 | 98 |
} |
99 | 99 |
if (state != null && state.containsKey("authenticating") && state.getBoolean("authenticating")) { |
100 |
Log.d("info", "captin on restore show"); |
|
101 | 100 |
showDialog(); |
102 | 101 |
} else { |
103 | 102 |
hideDialog(); |
... | ... | |
127 | 126 |
protected void onStop(){ |
128 | 127 |
super.onStop(); |
129 | 128 |
if(authenticating){ |
130 |
Log.d("info", "captin onstop called"); |
|
131 | 129 |
hideDialog(); |
132 | 130 |
authenticating = true; |
133 | 131 |
} |
... | ... | |
232 | 230 |
try { |
233 | 231 |
fis = openFileInput(FILENAME); |
234 | 232 |
in = new ObjectInputStream(fis); |
233 |
@SuppressWarnings("unchecked") |
|
235 | 234 |
ArrayList<Account> file = (ArrayList<Account>)in.readObject(); |
236 | 235 |
in.close(); |
237 | 236 |
return file; |
... | ... | |
427 | 426 |
|
428 | 427 |
@Override |
429 | 428 |
protected void onPreExecute(){ |
430 |
Log.d("info", "auth show called"); |
|
431 | 429 |
showDialog(); |
432 | 430 |
} |
433 | 431 |
|
b/src/com/rackspacecloud/android/ListLoadBalancersActivity.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancer; |
28 | 28 |
import com.rackspace.cloud.loadbalancer.api.client.LoadBalancerManager; |
29 |
import com.rackspace.cloud.loadbalancer.api.client.Protocol; |
|
30 |
import com.rackspace.cloud.loadbalancer.api.client.ProtocolManager; |
|
31 | 29 |
import com.rackspace.cloud.loadbalancers.api.client.http.LoadBalancersException; |
32 | 30 |
|
33 | 31 |
public class ListLoadBalancersActivity extends ListActivity { |
... | ... | |
201 | 199 |
|
202 | 200 |
// * Adapter/ |
203 | 201 |
class LoadBalancerAdapter extends ArrayAdapter<LoadBalancer> { |
204 |
private static final int RESULT_OK = 200; |
|
205 | 202 |
|
206 | 203 |
LoadBalancerAdapter() { |
207 | 204 |
super(ListLoadBalancersActivity.this, |
b/src/com/rackspacecloud/android/PasswordServerActivity.java | ||
---|---|---|
20 | 20 |
import android.content.Intent; |
21 | 21 |
import android.os.AsyncTask; |
22 | 22 |
import android.os.Bundle; |
23 |
import android.util.Log; |
|
24 | 23 |
import android.view.View; |
25 | 24 |
import android.view.View.OnClickListener; |
26 | 25 |
import android.widget.Button; |
b/src/com/rackspacecloud/android/ServerErrorActivity.java | ||
---|---|---|
3 | 3 |
import android.app.Activity; |
4 | 4 |
import android.content.Intent; |
5 | 5 |
import android.os.Bundle; |
6 |
import android.util.Log; |
|
7 | 6 |
import android.view.View; |
8 | 7 |
import android.view.View.OnClickListener; |
9 | 8 |
import android.view.Window; |
b/src/com/rackspacecloud/android/ViewLoadBalancerActivity.java | ||
---|---|---|
8 | 8 |
import android.app.ProgressDialog; |
9 | 9 |
import android.content.Context; |
10 | 10 |
import android.content.DialogInterface; |
11 |
import android.content.Intent; |
|
12 | 11 |
import android.os.AsyncTask; |
13 | 12 |
import android.os.Bundle; |
14 | 13 |
import android.util.Log; |
... | ... | |
26 | 25 |
|
27 | 26 |
public class ViewLoadBalancerActivity extends Activity { |
28 | 27 |
|
29 |
private final int EDIT_LOAD_BALANCER_CODE = 23; |
|
30 | 28 |
private LoadBalancer loadBalancer; |
31 | 29 |
private LoadBalancer returnLoadBalancer; |
32 | 30 |
private Context context; |
Also available in: Unified diff