Chromium Code Reviews| 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.app.AlertDialog; | 8 import android.app.AlertDialog; |
| 9 import android.app.ProgressDialog; | 9 import android.app.ProgressDialog; |
| 10 import android.content.DialogInterface; | 10 import android.content.DialogInterface; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 import android.widget.LinearLayout; | 29 import android.widget.LinearLayout; |
| 30 import android.widget.ListView; | 30 import android.widget.ListView; |
| 31 import android.widget.Toast; | 31 import android.widget.Toast; |
| 32 | 32 |
| 33 import org.chromium.base.ApiCompatibilityUtils; | 33 import org.chromium.base.ApiCompatibilityUtils; |
| 34 import org.chromium.base.Log; | 34 import org.chromium.base.Log; |
| 35 import org.chromium.chromoting.accountswitcher.AccountSwitcher; | 35 import org.chromium.chromoting.accountswitcher.AccountSwitcher; |
| 36 import org.chromium.chromoting.accountswitcher.AccountSwitcherFactory; | 36 import org.chromium.chromoting.accountswitcher.AccountSwitcherFactory; |
| 37 import org.chromium.chromoting.help.HelpContext; | 37 import org.chromium.chromoting.help.HelpContext; |
| 38 import org.chromium.chromoting.help.HelpSingleton; | 38 import org.chromium.chromoting.help.HelpSingleton; |
| 39 import org.chromium.chromoting.jni.Client; | |
| 39 import org.chromium.chromoting.jni.ConnectionListener; | 40 import org.chromium.chromoting.jni.ConnectionListener; |
| 40 import org.chromium.chromoting.jni.JniInterface; | 41 import org.chromium.chromoting.jni.JniInterface; |
| 41 | 42 |
| 42 import java.util.ArrayList; | 43 import java.util.ArrayList; |
| 43 import java.util.Arrays; | 44 import java.util.Arrays; |
| 44 | 45 |
| 45 /** | 46 /** |
| 46 * The user interface for querying and displaying a user's host list from the di rectory server. It | 47 * The user interface for querying and displaying a user's host list from the di rectory server. It |
| 47 * also requests and renews authentication tokens using the system account manag er. | 48 * also requests and renews authentication tokens using the system account manag er. |
| 48 */ | 49 */ |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 preferences.putString(prefName, recents[i]); | 329 preferences.putString(prefName, recents[i]); |
| 329 } | 330 } |
| 330 | 331 |
| 331 preferences.apply(); | 332 preferences.apply(); |
| 332 } | 333 } |
| 333 | 334 |
| 334 /** Called when the activity is finally finished. */ | 335 /** Called when the activity is finally finished. */ |
| 335 @Override | 336 @Override |
| 336 public void onDestroy() { | 337 public void onDestroy() { |
| 337 super.onDestroy(); | 338 super.onDestroy(); |
| 338 JniInterface.disconnectFromHost(); | 339 JniInterface.destroyClient(); |
| 339 mAccountSwitcher.destroy(); | 340 mAccountSwitcher.destroy(); |
| 340 } | 341 } |
| 341 | 342 |
| 342 /** Called when a child Activity exits and sends a result back to this Activ ity. */ | 343 /** Called when a child Activity exits and sends a result back to this Activ ity. */ |
| 343 @Override | 344 @Override |
| 344 public void onActivityResult(int requestCode, int resultCode, Intent data) { | 345 public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 345 mAccountSwitcher.onActivityResult(requestCode, resultCode, data); | 346 mAccountSwitcher.onActivityResult(requestCode, resultCode, data); |
| 346 | 347 |
| 347 if (requestCode == OAuthTokenFetcher.REQUEST_CODE_RECOVER_FROM_OAUTH_ERR OR) { | 348 if (requestCode == OAuthTokenFetcher.REQUEST_CODE_RECOVER_FROM_OAUTH_ERR OR) { |
| 348 if (resultCode == RESULT_OK) { | 349 if (resultCode == RESULT_OK) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 HostInfo host = mHosts[index]; | 424 HostInfo host = mHosts[index]; |
| 424 if (host.isOnline) { | 425 if (host.isOnline) { |
| 425 connectToHost(host); | 426 connectToHost(host); |
| 426 } else { | 427 } else { |
| 427 String tooltip = host.getHostOfflineReasonText(this); | 428 String tooltip = host.getHostOfflineReasonText(this); |
| 428 Toast.makeText(this, tooltip, Toast.LENGTH_SHORT).show(); | 429 Toast.makeText(this, tooltip, Toast.LENGTH_SHORT).show(); |
| 429 } | 430 } |
| 430 } | 431 } |
| 431 | 432 |
| 432 private void connectToHost(HostInfo host) { | 433 private void connectToHost(HostInfo host) { |
| 434 Client client = JniInterface.createClient(); | |
|
Sergey Ulanov
2015/12/21 17:58:15
Can this be replaced with "new Client()". The Clie
Lambros
2016/01/29 23:58:25
Done.
| |
| 433 mProgressIndicator = ProgressDialog.show( | 435 mProgressIndicator = ProgressDialog.show( |
| 434 this, | 436 this, |
| 435 host.name, | 437 host.name, |
| 436 getString(R.string.footer_connecting), | 438 getString(R.string.footer_connecting), |
| 437 true, | 439 true, |
| 438 true, | 440 true, |
| 439 new DialogInterface.OnCancelListener() { | 441 new DialogInterface.OnCancelListener() { |
| 440 @Override | 442 @Override |
| 441 public void onCancel(DialogInterface dialog) { | 443 public void onCancel(DialogInterface dialog) { |
| 442 JniInterface.disconnectFromHost(); | 444 JniInterface.destroyClient(); |
|
Sergey Ulanov
2015/12/21 17:58:15
client.destroy()?
Lambros
2016/01/29 23:58:25
Done.
| |
| 443 } | 445 } |
| 444 }); | 446 }); |
| 445 SessionConnector connector = new SessionConnector(this, this, mHostListL oader); | 447 SessionConnector connector = new SessionConnector(client, this, this, mH ostListLoader); |
| 446 mAuthenticator = new SessionAuthenticator(this, host); | 448 mAuthenticator = new SessionAuthenticator(this, client, host); |
| 447 connector.connectToHost(mAccount, mToken, host, mAuthenticator); | 449 connector.connectToHost(mAccount, mToken, host, mAuthenticator); |
| 448 } | 450 } |
| 449 | 451 |
| 450 private void refreshHostList() { | 452 private void refreshHostList() { |
| 451 if (mWaitingForAuthToken) { | 453 if (mWaitingForAuthToken) { |
| 452 return; | 454 return; |
| 453 } | 455 } |
| 454 | 456 |
| 455 mTriedNewAuthToken = false; | 457 mTriedNewAuthToken = false; |
| 456 setHostListProgressVisible(true); | 458 setHostListProgressVisible(true); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 // Unreachable, but required by Google Java style and findbugs. | 608 // Unreachable, but required by Google Java style and findbugs. |
| 607 assert false : "Unreached"; | 609 assert false : "Unreached"; |
| 608 } | 610 } |
| 609 | 611 |
| 610 if (dismissProgress && mProgressIndicator != null) { | 612 if (dismissProgress && mProgressIndicator != null) { |
| 611 mProgressIndicator.dismiss(); | 613 mProgressIndicator.dismiss(); |
| 612 mProgressIndicator = null; | 614 mProgressIndicator = null; |
| 613 } | 615 } |
| 614 } | 616 } |
| 615 } | 617 } |
| OLD | NEW |