OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chromoting; | 5 package org.chromium.chromoting; |
6 | 6 |
7 import android.accounts.Account; | 7 import android.accounts.Account; |
8 import android.accounts.AccountManager; | 8 import android.accounts.AccountManager; |
9 import android.accounts.AccountManagerCallback; | 9 import android.accounts.AccountManagerCallback; |
10 import android.accounts.AccountManagerFuture; | 10 import android.accounts.AccountManagerFuture; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 /** Web page to be displayed when user triggers the hyperlink for setting up hosts. */ | 54 /** Web page to be displayed when user triggers the hyperlink for setting up hosts. */ |
55 private static final String HOST_SETUP_URL = | 55 private static final String HOST_SETUP_URL = |
56 "https://support.google.com/chrome/answer/1649523"; | 56 "https://support.google.com/chrome/answer/1649523"; |
57 | 57 |
58 /** User's account details. */ | 58 /** User's account details. */ |
59 private Account mAccount; | 59 private Account mAccount; |
60 | 60 |
61 /** List of accounts on the system. */ | 61 /** List of accounts on the system. */ |
62 private Account[] mAccounts; | 62 private Account[] mAccounts; |
63 | 63 |
64 /** SpinnerAdapter used in the action bar for selecting accounts. */ | |
65 private AccountsAdapter mAccountsAdapter; | |
66 | |
64 /** Account auth token. */ | 67 /** Account auth token. */ |
65 private String mToken; | 68 private String mToken; |
66 | 69 |
67 /** Helper for fetching the host list. */ | 70 /** Helper for fetching the host list. */ |
68 private HostListLoader mHostListLoader; | 71 private HostListLoader mHostListLoader; |
69 | 72 |
70 /** List of hosts. */ | 73 /** List of hosts. */ |
71 private HostInfo[] mHosts = new HostInfo[0]; | 74 private HostInfo[] mHosts = new HostInfo[0]; |
72 | 75 |
73 /** Refresh button. */ | 76 /** Refresh button. */ |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 // first account arbitrarily. | 187 // first account arbitrarily. |
185 index = 0; | 188 index = 0; |
186 mAccount = mAccounts[0]; | 189 mAccount = mAccounts[0]; |
187 } | 190 } |
188 | 191 |
189 if (mAccounts.length == 1) { | 192 if (mAccounts.length == 1) { |
190 getActionBar().setDisplayShowTitleEnabled(true); | 193 getActionBar().setDisplayShowTitleEnabled(true); |
191 getActionBar().setTitle(R.string.mode_me2me); | 194 getActionBar().setTitle(R.string.mode_me2me); |
192 getActionBar().setSubtitle(mAccount.name); | 195 getActionBar().setSubtitle(mAccount.name); |
193 } else { | 196 } else { |
194 AccountsAdapter adapter = new AccountsAdapter(this, mAccounts); | 197 mAccountsAdapter = new AccountsAdapter(this, mAccounts); |
195 getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); | 198 getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); |
196 getActionBar().setListNavigationCallbacks(adapter, this); | 199 getActionBar().setListNavigationCallbacks(mAccountsAdapter, this); |
197 getActionBar().setSelectedNavigationItem(index); | 200 getActionBar().setSelectedNavigationItem(index); |
198 } | 201 } |
199 | 202 |
200 refreshHostList(); | 203 refreshHostList(); |
201 } | 204 } |
202 | 205 |
203 /** Called when the activity is finally finished. */ | 206 /** Called when the activity is finally finished. */ |
204 @Override | 207 @Override |
205 public void onDestroy() { | 208 public void onDestroy() { |
206 super.onDestroy(); | 209 super.onDestroy(); |
207 JniInterface.disconnectFromHost(); | 210 JniInterface.disconnectFromHost(); |
208 } | 211 } |
209 | 212 |
210 /** Called when the display is rotated (as registered in the manifest). */ | 213 /** Called when the display is rotated (as registered in the manifest). */ |
211 @Override | 214 @Override |
212 public void onConfigurationChanged(Configuration newConfig) { | 215 public void onConfigurationChanged(Configuration newConfig) { |
213 super.onConfigurationChanged(newConfig); | 216 super.onConfigurationChanged(newConfig); |
214 | 217 |
215 // Reload the spinner resources, since the font sizes are dependent on t he screen | 218 // Reload the spinner resources, since the font sizes are dependent on t he screen |
216 // orientation. | 219 // orientation. |
Jamie
2014/03/27 02:06:32
Is this comment still accurate?
Lambros
2014/03/27 02:13:19
Yes. The font styles in the spinner are defined to
| |
217 if (mAccounts.length != 1) { | 220 if (mAccounts.length != 1) { |
218 AccountsAdapter adapter = new AccountsAdapter(this, mAccounts); | 221 mAccountsAdapter.notifyDataSetChanged(); |
219 getActionBar().setListNavigationCallbacks(adapter, this); | |
220 } | 222 } |
221 } | 223 } |
222 | 224 |
223 /** Called to initialize the action bar. */ | 225 /** Called to initialize the action bar. */ |
224 @Override | 226 @Override |
225 public boolean onCreateOptionsMenu(Menu menu) { | 227 public boolean onCreateOptionsMenu(Menu menu) { |
226 getMenuInflater().inflate(R.menu.chromoting_actionbar, menu); | 228 getMenuInflater().inflate(R.menu.chromoting_actionbar, menu); |
227 mRefreshButton = menu.findItem(R.id.actionbar_directoryrefresh); | 229 mRefreshButton = menu.findItem(R.id.actionbar_directoryrefresh); |
228 | 230 |
229 if (mAccount == null) { | 231 if (mAccount == null) { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 // Unreachable, but required by Google Java style and findbugs. | 437 // Unreachable, but required by Google Java style and findbugs. |
436 assert false : "Unreached"; | 438 assert false : "Unreached"; |
437 } | 439 } |
438 | 440 |
439 if (dismissProgress && mProgressIndicator != null) { | 441 if (dismissProgress && mProgressIndicator != null) { |
440 mProgressIndicator.dismiss(); | 442 mProgressIndicator.dismiss(); |
441 mProgressIndicator = null; | 443 mProgressIndicator = null; |
442 } | 444 } |
443 } | 445 } |
444 } | 446 } |
OLD | NEW |