Revision d88d3ae1 src/com/rackspacecloud/android/ListAccountsActivity.java
b/src/com/rackspacecloud/android/ListAccountsActivity.java | ||
---|---|---|
119 | 119 |
out.flush(); |
120 | 120 |
out.close(); |
121 | 121 |
} catch (FileNotFoundException e) { |
122 |
// TODO Auto-generated catch block
|
|
122 |
showAlert("Error", "Could not save accounts.");
|
|
123 | 123 |
e.printStackTrace(); |
124 | 124 |
} catch (IOException e) { |
125 |
// TODO Auto-generated catch block
|
|
125 |
showAlert("Error", "Could not save accounts.");
|
|
126 | 126 |
e.printStackTrace(); |
127 | 127 |
} |
128 | 128 |
} |
... | ... | |
138 | 138 |
Log.d("captin", Boolean.toString(file == null)); |
139 | 139 |
return file; |
140 | 140 |
} catch (FileNotFoundException e) { |
141 |
// TODO Auto-generated catch block
|
|
141 |
//showAlert("Error", "Could not load accounts.");
|
|
142 | 142 |
e.printStackTrace(); |
143 | 143 |
return null; |
144 | 144 |
} catch (StreamCorruptedException e) { |
145 |
// TODO Auto-generated catch block
|
|
145 |
showAlert("Error", "Could not load accounts.");
|
|
146 | 146 |
e.printStackTrace(); |
147 | 147 |
} catch (IOException e) { |
148 |
// TODO Auto-generated catch block
|
|
148 |
showAlert("Error", "Could not load accounts.");
|
|
149 | 149 |
e.printStackTrace(); |
150 | 150 |
} catch (ClassNotFoundException e) { |
151 |
// TODO Auto-generated catch block
|
|
151 |
showAlert("Error", "Could not load accounts.");
|
|
152 | 152 |
e.printStackTrace(); |
153 | 153 |
} |
154 | 154 |
return null; |
... | ... | |
233 | 233 |
sublabel.setText(getAccountServer(accounts.get(position))); |
234 | 234 |
|
235 | 235 |
ImageView icon = (ImageView) row.findViewById(R.id.account_type_icon); |
236 |
icon.setImageResource(R.drawable.rackspace60);
|
|
236 |
icon.setImageResource(setAccountIcon(accounts.get(position)));
|
|
237 | 237 |
|
238 | 238 |
return row; |
239 | 239 |
} |
... | ... | |
241 | 241 |
|
242 | 242 |
public String getAccountServer(Account account){ |
243 | 243 |
String authServer = account.getAuthServer(); |
244 |
String result = "Rackspace Cloud"; |
|
245 |
if(authServer.contains("lon")){ |
|
246 |
result += " (UK)"; |
|
244 |
String result; |
|
245 |
if(authServer.equals(Preferences.COUNTRY_UK_AUTH_SERVER)){ |
|
246 |
result = "Rackspace Cloud (UK)"; |
|
247 |
} |
|
248 |
else if(authServer.equals(Preferences.COUNTRY_US_AUTH_SERVER)){ |
|
249 |
result = "Rackspace Cloud (US)"; |
|
247 | 250 |
} |
248 | 251 |
else{ |
249 |
result += " (US)"; |
|
252 |
result = "Custom"; |
|
253 |
//setCustomIcon(); |
|
250 | 254 |
} |
251 | 255 |
return result; |
252 | 256 |
} |
257 |
|
|
258 |
//display rackspace logo for cloud accounts and openstack logo for others |
|
259 |
private int setAccountIcon(Account account){ |
|
260 |
if(account.getAuthServer().equals(Preferences.COUNTRY_UK_AUTH_SERVER) |
|
261 |
|| account.getAuthServer().equals(Preferences.COUNTRY_US_AUTH_SERVER)){ |
|
262 |
return R.drawable.rackspacecloud_icon; |
|
263 |
} |
|
264 |
else{ |
|
265 |
return R.drawable.openstack_icon; |
|
266 |
} |
|
267 |
} |
|
253 | 268 |
|
254 | 269 |
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
255 | 270 |
super.onActivityResult(requestCode, resultCode, data); |
... | ... | |
260 | 275 |
acc.setApiKey(b.getString("apiKey")); |
261 | 276 |
acc.setUsername(b.getString("username")); |
262 | 277 |
acc.setAuthServer(b.getString("server")); |
278 |
Log.d("captin captin!", acc.getAuthServer()); |
|
263 | 279 |
accounts.add(acc); |
264 | 280 |
writeAccounts(); |
265 | 281 |
loadAccounts(); |
Also available in: Unified diff