diff options
author | John Reck <jreck@google.com> | 2011-03-14 16:28:56 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-03-14 16:28:56 -0700 |
commit | f94df7eb15fcbca9e47d5163f087fa1425c4511d (patch) | |
tree | 281b6b66cee3378c9f430b1acf6254aa146472b0 /src | |
parent | ac7538e0a49911b926eeebb811f61c6996c68ae3 (diff) | |
download | packages_apps_Browser-f94df7eb15fcbca9e47d5163f087fa1425c4511d.zip packages_apps_Browser-f94df7eb15fcbca9e47d5163f087fa1425c4511d.tar.gz packages_apps_Browser-f94df7eb15fcbca9e47d5163f087fa1425c4511d.tar.bz2 |
Switch account spinner to dropdown and holo style
Bug: 4093519
Change-Id: I0ac4670b325557616c24f024d86a85cf2e1ff141
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/DeviceAccountLogin.java | 41 | ||||
-rw-r--r-- | src/com/android/browser/TitleBarXLarge.java | 37 |
2 files changed, 29 insertions, 49 deletions
diff --git a/src/com/android/browser/DeviceAccountLogin.java b/src/com/android/browser/DeviceAccountLogin.java index 50b8c97..818e076 100644 --- a/src/com/android/browser/DeviceAccountLogin.java +++ b/src/com/android/browser/DeviceAccountLogin.java @@ -21,22 +21,18 @@ import android.accounts.AccountManager; import android.accounts.AccountManagerCallback; import android.accounts.AccountManagerFuture; import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; import android.os.Bundle; import android.webkit.WebView; -import android.webkit.WebViewClient; public class DeviceAccountLogin implements - AccountManagerCallback<Bundle>, DialogInterface.OnClickListener { + AccountManagerCallback<Bundle> { private final Activity mActivity; private final WebView mWebView; private final Tab mTab; private final WebViewController mWebViewController; private final AccountManager mAccountManager; - private Account[] mAccounts; - private int mCurrentAccount; + Account[] mAccounts; private AutoLoginCallback mCallback; private String mAuthToken; @@ -48,7 +44,6 @@ public class DeviceAccountLogin implements public static final int PROCESSING = 2; public interface AutoLoginCallback { - public void setAccount(String account); public void loginFailed(); } @@ -129,37 +124,19 @@ public class DeviceAccountLogin implements mTab.setDeviceAccountLogin(null); } - public void login(AutoLoginCallback cb) { + public void login(int accountIndex, AutoLoginCallback cb) { mState = PROCESSING; mCallback = cb; mAccountManager.getAuthToken( - mAccounts[mCurrentAccount], mAuthToken, null, + mAccounts[accountIndex], mAuthToken, null, mActivity, this, null); } - public void chooseAccount(AutoLoginCallback cb) { - mCallback = cb; - CharSequence[] names = new CharSequence[mAccounts.length]; - int i = 0; - for (Account a : mAccounts) { - names[i++] = a.name; + public String[] getAccountNames() { + String[] names = new String[mAccounts.length]; + for (int i = 0; i < mAccounts.length; i++) { + names[i] = mAccounts[i].name; } - new AlertDialog.Builder(mActivity) - .setTitle(R.string.pref_autologin_title) - .setSingleChoiceItems(names, mCurrentAccount, this) - .setCancelable(true) - .show(); - } - - public String getCurrentAccount() { - return mAccounts[mCurrentAccount].name; - } - - @Override - public void onClick(DialogInterface d, int which) { - assert mCallback != null; - mCallback.setAccount(mAccounts[which].name); - mCurrentAccount = which; - d.dismiss(); + return names; } } diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java index a786fd7..f53bc35 100644 --- a/src/com/android/browser/TitleBarXLarge.java +++ b/src/com/android/browser/TitleBarXLarge.java @@ -20,28 +20,32 @@ import com.android.browser.UI.DropdownChangeListener; import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatcher; import com.android.browser.search.SearchEngine; +import android.accounts.Account; import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.text.TextUtils; -import android.view.animation.Animation; -import android.view.animation.Animation.AnimationListener; -import android.view.animation.AnimationUtils; +import android.view.ContextThemeWrapper; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnFocusChangeListener; import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.Animation.AnimationListener; +import android.view.animation.AnimationUtils; import android.webkit.WebView; import android.widget.AbsoluteLayout; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ProgressBar; +import android.widget.Spinner; import android.widget.TextView; import java.util.List; @@ -75,12 +79,13 @@ public class TitleBarXLarge extends TitleBarBase private Drawable mUnfocusDrawable; // Auto-login UI private View mAutoLogin; - private Button mAutoLoginAccount; + private Spinner mAutoLoginAccount; private Button mAutoLoginLogin; private ProgressBar mAutoLoginProgress; private TextView mAutoLoginError; private ImageButton mAutoLoginCancel; private DeviceAccountLogin mAutoLoginHandler; + private ArrayAdapter<String> mAccountsAdapter; private boolean mInLoad; private boolean mUseQuickControls; @@ -149,8 +154,7 @@ public class TitleBarXLarge extends TitleBarBase mUrlInput.setSelectAllOnFocus(true); mUrlInput.addQueryTextWatcher(this); mAutoLogin = findViewById(R.id.autologin); - mAutoLoginAccount = (Button) findViewById(R.id.autologin_account); - mAutoLoginAccount.setOnClickListener(this); + mAutoLoginAccount = (Spinner) findViewById(R.id.autologin_account); mAutoLoginLogin = (Button) findViewById(R.id.autologin_login); mAutoLoginLogin.setOnClickListener(this); mAutoLoginProgress = @@ -180,7 +184,14 @@ public class TitleBarXLarge extends TitleBarBase if (login != null) { mAutoLoginHandler = login; mAutoLogin.setVisibility(View.VISIBLE); - mAutoLoginAccount.setText(login.getCurrentAccount()); + ContextThemeWrapper wrapper = new ContextThemeWrapper(mContext, + android.R.style.Theme_Holo_Light); + mAccountsAdapter = new ArrayAdapter<String>(wrapper, + android.R.layout.simple_spinner_item, login.getAccountNames()); + mAccountsAdapter.setDropDownViewResource( + android.R.layout.simple_spinner_dropdown_item); + mAutoLoginAccount.setAdapter(mAccountsAdapter); + mAutoLoginAccount.setSelection(0); mAutoLoginAccount.setEnabled(true); mAutoLoginLogin.setEnabled(true); mAutoLoginProgress.setVisibility(View.GONE); @@ -353,21 +364,13 @@ public class TitleBarXLarge extends TitleBarBase mAutoLoginLogin.setEnabled(false); mAutoLoginProgress.setVisibility(View.VISIBLE); mAutoLoginError.setVisibility(View.GONE); - mAutoLoginHandler.login(this); - } - } else if (mAutoLoginAccount == v) { - if (mAutoLoginHandler != null) { - mAutoLoginHandler.chooseAccount(this); + mAutoLoginHandler.login( + mAutoLoginAccount.getSelectedItemPosition(), this); } } } @Override - public void setAccount(String account) { - mAutoLoginAccount.setText(account); - } - - @Override public void loginFailed() { mAutoLoginAccount.setEnabled(true); mAutoLoginLogin.setEnabled(true); |