summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/Development/AndroidManifest.xml1
-rw-r--r--apps/Development/res/layout/accounts_tester.xml192
-rw-r--r--apps/Development/res/layout/get_auth_token_view.xml3
-rw-r--r--apps/Development/res/layout/get_features_view.xml51
-rw-r--r--apps/Development/res/values/strings.xml4
-rw-r--r--apps/Development/src/com/android/development/AccountsTester.java135
6 files changed, 251 insertions, 135 deletions
diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml
index c91e21be3..ffee933e5 100644
--- a/apps/Development/AndroidManifest.xml
+++ b/apps/Development/AndroidManifest.xml
@@ -78,7 +78,6 @@
</activity>
<activity android:name="AccountsTester" android:label="AccountsTester"
- android:theme="@android:style/Theme.Light"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/apps/Development/res/layout/accounts_tester.xml b/apps/Development/res/layout/accounts_tester.xml
index df7c73fe4..28f1b4e2e 100644
--- a/apps/Development/res/layout/accounts_tester.xml
+++ b/apps/Development/res/layout/accounts_tester.xml
@@ -14,100 +14,110 @@
limitations under the License.
-->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <TextView android:id="@+id/accounts_tester_account_types_spinner_label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/accounts_tester_select_account_type"/>
-
- <Spinner android:id="@+id/accounts_tester_account_types_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
- </LinearLayout>
-
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <Button
- android:id="@+id/accounts_tester_get_accounts_by_type"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/accounts_tester_get_accounts_by_type"/>
-
- <Button
- android:id="@+id/accounts_tester_get_all_accounts"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/accounts_tester_get_all_accounts"/>
- <Button android:id="@+id/accounts_tester_add_account"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/accounts_tester_add_account"/>
-
- <Button android:id="@+id/accounts_tester_edit_properties"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/accounts_tester_edit_properties"/>
- </LinearLayout>
-
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <TextView android:id="@+id/accounts_tester_desiredFeatures"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/accounts_tester_desired_features_label"/>
-
- <EditText android:id="@+id/accounts_tester_desired_features"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minEms="15"/>
- </LinearLayout>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <TextView android:id="@+id/accounts_tester_desiredFeatures"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/accounts_tester_desired_authtokentype_label"/>
-
- <EditText android:id="@+id/accounts_tester_desired_authtokentype"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minEms="15"/>
- </LinearLayout>
- </LinearLayout>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView android:id="@+id/accounts_tester_account_types_spinner_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_select_account_type"/>
+
+ <Spinner android:id="@+id/accounts_tester_account_types_spinner"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+ </LinearLayout>
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button
+ android:id="@+id/accounts_tester_get_accounts_by_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_get_accounts_by_type"/>
+
+ <Button
+ android:id="@+id/accounts_tester_get_all_accounts"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_get_all_accounts"/>
+
+ <Button android:id="@+id/accounts_tester_add_account"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_add_account"/>
+
+ <Button android:id="@+id/accounts_tester_edit_properties"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_edit_properties"/>
+
+ <Button android:id="@+id/accounts_tester_get_auth_token_by_type_and_feature"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_get_auth_token_by_type_and_feature"/>
+
+ </LinearLayout>
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView android:id="@+id/accounts_tester_desiredFeatures"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_desired_features_label"/>
+
+ <EditText android:id="@+id/accounts_tester_desired_features"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minEms="15"/>
+ </LinearLayout>
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView android:id="@+id/accounts_tester_desiredFeatures"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_desired_authtokentype_label"/>
+
+ <EditText android:id="@+id/accounts_tester_desired_authtokentype"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minEms="15"/>
+ </LinearLayout>
+ </LinearLayout>
</LinearLayout>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
- <ListView android:id="@+id/accounts_tester_accounts_list"
- android:layout_width="match_parent" android:layout_height="match_parent"/>
+ <ListView android:id="@+id/accounts_tester_accounts_list"
+ android:layout_width="match_parent" android:layout_height="match_parent"/>
</LinearLayout>
diff --git a/apps/Development/res/layout/get_auth_token_view.xml b/apps/Development/res/layout/get_auth_token_view.xml
index c014cad60..cfaed321c 100644
--- a/apps/Development/res/layout/get_auth_token_view.xml
+++ b/apps/Development/res/layout/get_auth_token_view.xml
@@ -21,7 +21,8 @@
android:layout_height="match_parent">
<TextView android:id="@+id/accounts_tester_get_auth_token_dialog_message"
- android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
android:text="@string/accounts_tester_enter_auth_token_type" />
<EditText android:id="@+id/accounts_tester_auth_token_type"
diff --git a/apps/Development/res/layout/get_features_view.xml b/apps/Development/res/layout/get_features_view.xml
new file mode 100644
index 000000000..02fde2878
--- /dev/null
+++ b/apps/Development/res/layout/get_features_view.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView android:id="@+id/accounts_tester_get_auth_token_dialog_message"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_enter_auth_token_type" />
+
+ <EditText android:id="@+id/accounts_tester_auth_token_type"
+ android:singleLine="true"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minWidth="250dip"
+ android:scrollHorizontally="true"
+ android:capitalize="none"
+ android:autoText="false"/>
+
+ <TextView android:id="@+id/accounts_tester_get_features_dialog_message"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/accounts_tester_enter_features" />
+
+ <EditText android:id="@+id/accounts_tester_features"
+ android:singleLine="true"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minWidth="250dip"
+ android:scrollHorizontally="true"
+ android:capitalize="none"
+ android:autoText="false"/>
+
+</LinearLayout>
diff --git a/apps/Development/res/values/strings.xml b/apps/Development/res/values/strings.xml
index 422bd7f59..5d8a927ae 100644
--- a/apps/Development/res/values/strings.xml
+++ b/apps/Development/res/values/strings.xml
@@ -171,11 +171,13 @@
<string name="accounts_tester_process_name_header">Process Name:</string>
<string name="accounts_tester_remove_account">Remove Account</string>
<string name="accounts_tester_get_auth_token">Get Auth Token</string>
+ <string name="accounts_tester_get_auth_token_by_type_and_feature">Get Auth Token By Type/Feature</string>
<string name="accounts_tester_test_has_features">Has Features</string>
<string name="accounts_tester_invalidate_auth_token">Invalidate Token</string>
<string name="accounts_tester_account_context_menu_title">account operations</string>
- <string name="accounts_tester_do_get_auth_token">Ok</string>
+ <string name="accounts_tester_ok_button">Ok</string>
<string name="accounts_tester_enter_auth_token_type">Enter the authtoken type:</string>
+ <string name="accounts_tester_enter_features">Enter the features separated by a space:</string>
<string name="accounts_tester_update_credentials">Update Credentials</string>
<string name="accounts_tester_confirm_credentials">Confirm Credentials</string>
<string name="accounts_tester_clear_password">Clear Password</string>
diff --git a/apps/Development/src/com/android/development/AccountsTester.java b/apps/Development/src/com/android/development/AccountsTester.java
index f8ff73683..e2a0789b8 100644
--- a/apps/Development/src/com/android/development/AccountsTester.java
+++ b/apps/Development/src/com/android/development/AccountsTester.java
@@ -46,6 +46,8 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener
private static final int INVALIDATE_AUTH_TOKEN_DIALOG_ID = 3;
private static final int TEST_HAS_FEATURES_DIALOG_ID = 4;
private static final int MESSAGE_DIALOG_ID = 5;
+ private static final int GET_AUTH_TOKEN_BY_TYPE_AND_FEATURE_DIALOG_ID = 6;
+
private EditText mDesiredAuthTokenTypeEditText;
private EditText mDesiredFeaturesEditText;
private volatile CharSequence mDialogMessage;
@@ -66,6 +68,8 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener
buttonClickListener);
findViewById(R.id.accounts_tester_add_account).setOnClickListener(buttonClickListener);
findViewById(R.id.accounts_tester_edit_properties).setOnClickListener(buttonClickListener);
+ findViewById(R.id.accounts_tester_get_auth_token_by_type_and_feature).setOnClickListener(
+ buttonClickListener);
mDesiredAuthTokenTypeEditText =
(EditText) findViewById(R.id.accounts_tester_desired_authtokentype);
mDesiredFeaturesEditText = (EditText) findViewById(R.id.accounts_tester_desired_features);
@@ -119,8 +123,10 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener
if (desc.type.equals(account.type)) {
final String packageName = desc.packageName;
try {
- final Context authContext = getContext().createPackageContext(packageName, 0);
- holder.icon.setImageDrawable(authContext.getResources().getDrawable(desc.iconId));
+ final Context authContext = getContext().createPackageContext(packageName,
+ 0);
+ holder.icon.setImageDrawable(authContext.getResources().getDrawable(
+ desc.iconId));
holder.icon.setVisibility(View.VISIBLE);
} catch (PackageManager.NameNotFoundException e) {
Log.d(TAG, "error getting the Package Context for " + packageName, e);
@@ -197,6 +203,8 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener
AccountsTester.this,
new CallbackToDialog(AccountsTester.this, "edit properties"),
null /* handler */);
+ } else if (R.id.accounts_tester_get_auth_token_by_type_and_feature == v.getId()) {
+ showDialog(GET_AUTH_TOKEN_BY_TYPE_AND_FEATURE_DIALOG_ID);
} else {
// unknown button
}
@@ -265,48 +273,92 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener
@Override
protected Dialog onCreateDialog(final int id) {
- if (id == GET_AUTH_TOKEN_DIALOG_ID || id == INVALIDATE_AUTH_TOKEN_DIALOG_ID
- || id == UPDATE_CREDENTIALS_DIALOG_ID || id == TEST_HAS_FEATURES_DIALOG_ID) {
- final View view = LayoutInflater.from(this).inflate(R.layout.get_auth_token_view, null);
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setPositiveButton(R.string.accounts_tester_do_get_auth_token,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- EditText value = (EditText) view.findViewById(
- R.id.accounts_tester_auth_token_type);
-
- String authTokenType = value.getText().toString();
- final Account account = mLongPressedAccount;
- if (id == GET_AUTH_TOKEN_DIALOG_ID) {
- mAccountManager.getAuthToken(account, authTokenType,
- null /* loginOptions */, AccountsTester.this,
- new CallbackToDialog(AccountsTester.this, "get auth token"),
- null /* handler */);
- } else if (id == INVALIDATE_AUTH_TOKEN_DIALOG_ID) {
- mAccountManager.getAuthToken(account, authTokenType, false,
- new GetAndInvalidateAuthTokenCallback(account), null);
- } else if (id == TEST_HAS_FEATURES_DIALOG_ID) {
- String[] features = TextUtils.split(authTokenType, ",");
- mAccountManager.hasFeatures(account, features,
- new TestHasFeaturesCallback(), null);
- } else {
- mAccountManager.updateCredentials(
- account,
- authTokenType, null /* loginOptions */,
+ switch (id) {
+ case GET_AUTH_TOKEN_DIALOG_ID:
+ case INVALIDATE_AUTH_TOKEN_DIALOG_ID:
+ case UPDATE_CREDENTIALS_DIALOG_ID:
+ case TEST_HAS_FEATURES_DIALOG_ID: {
+ final View view = LayoutInflater.from(this).inflate(R.layout.get_auth_token_view,
+ null);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setPositiveButton(R.string.accounts_tester_ok_button,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ EditText value = (EditText) view.findViewById(
+ R.id.accounts_tester_auth_token_type);
+
+ String authTokenType = value.getText().toString();
+ final Account account = mLongPressedAccount;
+ if (id == GET_AUTH_TOKEN_DIALOG_ID) {
+ mAccountManager.getAuthToken(account,
+ authTokenType,
+ null /* loginOptions */,
+ AccountsTester.this,
+ new CallbackToDialog(AccountsTester.this,
+ "get auth token"),
+ null /* handler */);
+ } else if (id == INVALIDATE_AUTH_TOKEN_DIALOG_ID) {
+ mAccountManager.getAuthToken(account, authTokenType, false,
+ new GetAndInvalidateAuthTokenCallback(account), null);
+ } else if (id == TEST_HAS_FEATURES_DIALOG_ID) {
+ String[] features = TextUtils.split(authTokenType, ",");
+ mAccountManager.hasFeatures(account, features,
+ new TestHasFeaturesCallback(), null);
+ } else {
+ mAccountManager.updateCredentials(
+ account,
+ authTokenType, null /* loginOptions */,
+ AccountsTester.this,
+ new CallbackToDialog(AccountsTester.this, "update"),
+ null /* handler */);
+ }
+ }
+ });
+ builder.setView(view);
+ return builder.create();
+ }
+
+ case GET_AUTH_TOKEN_BY_TYPE_AND_FEATURE_DIALOG_ID: {
+ final View view = LayoutInflater.from(this).inflate(R.layout.get_features_view,
+ null);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setPositiveButton(R.string.accounts_tester_ok_button,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ EditText value = (EditText) view.findViewById(
+ R.id.accounts_tester_auth_token_type);
+
+ String authTokenType = value.getText().toString();
+
+ value = (EditText) view.findViewById(
+ R.id.accounts_tester_features);
+
+ String features = value.getText().toString();
+
+ final Account account = mLongPressedAccount;
+ mAccountManager.getAuthTokenByFeatures(
+ getSelectedAuthenticator().type,
+ authTokenType,
+ TextUtils.isEmpty(features) ? null : features.split(" "),
AccountsTester.this,
- new CallbackToDialog(AccountsTester.this, "update"),
+ null /* addAccountOptions */,
+ null /* getAuthTokenOptions */,
+ new CallbackToDialog(AccountsTester.this,
+ "get auth token by features"),
null /* handler */);
}
- }
- });
- builder.setView(view);
- return builder.create();
- }
- if (id == MESSAGE_DIALOG_ID) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(mDialogMessage);
- return builder.create();
+ });
+ builder.setView(view);
+ return builder.create();
+ }
+
+ case MESSAGE_DIALOG_ID: {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(mDialogMessage);
+ return builder.create();
+ }
}
+
return super.onCreateDialog(id);
}
@@ -344,7 +396,8 @@ public class AccountsTester extends Activity implements OnAccountsUpdateListener
}
}
- AccountManagerCallback<Bundle> newAuthTokensCallback(String type, String authTokenType, String[] features) {
+ AccountManagerCallback<Bundle> newAuthTokensCallback(String type, String authTokenType,
+ String[] features) {
return new GetAuthTokenCallback(type, authTokenType, features);
}