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; |
11 import android.accounts.AuthenticatorException; | 11 import android.accounts.AuthenticatorException; |
12 import android.accounts.OperationCanceledException; | 12 import android.accounts.OperationCanceledException; |
13 import android.annotation.TargetApi; | |
13 import android.app.ActionBar; | 14 import android.app.ActionBar; |
14 import android.app.Activity; | 15 import android.app.Activity; |
15 import android.app.AlertDialog; | 16 import android.app.AlertDialog; |
16 import android.app.ProgressDialog; | 17 import android.app.ProgressDialog; |
17 import android.content.DialogInterface; | 18 import android.content.DialogInterface; |
18 import android.content.Intent; | 19 import android.content.Intent; |
19 import android.content.SharedPreferences; | 20 import android.content.SharedPreferences; |
20 import android.content.res.Configuration; | 21 import android.content.res.Configuration; |
22 import android.os.Build; | |
21 import android.os.Bundle; | 23 import android.os.Bundle; |
22 import android.provider.Settings; | 24 import android.provider.Settings; |
23 import android.util.Log; | 25 import android.util.Log; |
24 import android.view.Menu; | 26 import android.view.Menu; |
25 import android.view.MenuItem; | 27 import android.view.MenuItem; |
26 import android.view.View; | 28 import android.view.View; |
27 import android.widget.ArrayAdapter; | 29 import android.widget.ArrayAdapter; |
28 import android.widget.ListView; | 30 import android.widget.ListView; |
29 import android.widget.Toast; | 31 import android.widget.Toast; |
30 | 32 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 * used to request the host list a second time. | 93 * used to request the host list a second time. |
92 */ | 94 */ |
93 boolean mTriedNewAuthToken; | 95 boolean mTriedNewAuthToken; |
94 | 96 |
95 /** Shows a warning explaining that a Google account is required, then close s the activity. */ | 97 /** Shows a warning explaining that a Google account is required, then close s the activity. */ |
96 private void showNoAccountsDialog() { | 98 private void showNoAccountsDialog() { |
97 AlertDialog.Builder builder = new AlertDialog.Builder(this); | 99 AlertDialog.Builder builder = new AlertDialog.Builder(this); |
98 builder.setMessage(R.string.noaccounts_message); | 100 builder.setMessage(R.string.noaccounts_message); |
99 builder.setPositiveButton(R.string.noaccounts_add_account, | 101 builder.setPositiveButton(R.string.noaccounts_add_account, |
100 new DialogInterface.OnClickListener() { | 102 new DialogInterface.OnClickListener() { |
103 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) | |
101 @Override | 104 @Override |
102 public void onClick(DialogInterface dialog, int id) { | 105 public void onClick(DialogInterface dialog, int id) { |
103 Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT); | 106 Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT); |
104 intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, | 107 intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, |
garykac
2014/05/12 17:37:14
Doesn't this code need a
if (Build.VERSION.SDK
Lambros
2014/05/12 20:39:29
I'm not sure. It works fine on an older device wit
newt (away)
2014/05/13 04:04:47
Correct. Constants on Android are typically static
| |
105 new String[] { ACCOUNT_TYPE }); | 108 new String[] { ACCOUNT_TYPE }); |
106 if (intent.resolveActivity(getPackageManager()) != null) { | 109 if (intent.resolveActivity(getPackageManager()) != null) { |
107 startActivity(intent); | 110 startActivity(intent); |
108 } | 111 } |
109 finish(); | 112 finish(); |
110 } | 113 } |
111 }); | 114 }); |
112 builder.setNegativeButton(R.string.close, new DialogInterface.OnClickLis tener() { | 115 builder.setNegativeButton(R.string.close, new DialogInterface.OnClickLis tener() { |
113 @Override | 116 @Override |
114 public void onClick(DialogInterface dialog, int id) { | 117 public void onClick(DialogInterface dialog, int id) { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 // Unreachable, but required by Google Java style and findbugs. | 440 // Unreachable, but required by Google Java style and findbugs. |
438 assert false : "Unreached"; | 441 assert false : "Unreached"; |
439 } | 442 } |
440 | 443 |
441 if (dismissProgress && mProgressIndicator != null) { | 444 if (dismissProgress && mProgressIndicator != null) { |
442 mProgressIndicator.dismiss(); | 445 mProgressIndicator.dismiss(); |
443 mProgressIndicator = null; | 446 mProgressIndicator = null; |
444 } | 447 } |
445 } | 448 } |
446 } | 449 } |
OLD | NEW |