Moving SelectAccountDialogFragment to ContactsCommon.
In preparation to move ImportExportDialogFragment to common.
Also moved a few more string resources left out from previous move.
Bug: 6993891
Change-Id: I2ddb6467732c53a70bc94c4cd0c702346ccb54fe
diff --git a/res/layout/account_selector_list_item.xml b/res/layout/account_selector_list_item.xml
deleted file mode 100644
index 4cba3e9..0000000
--- a/res/layout/account_selector_list_item.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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:layout_width="match_parent"
- android:layout_height="?android:attr/listPreferredItemHeight"
- android:orientation="horizontal">
- <ImageView android:id="@android:id/icon"
- android:layout_width="@dimen/detail_network_icon_size"
- android:layout_height="@dimen/detail_network_icon_size"
- android:layout_margin="8dip"
- android:layout_gravity="center_vertical" />
-
- <LinearLayout
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="vertical"
- android:layout_gravity="center_vertical">
-
- <TextView android:id="@android:id/text1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="8dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true"
- android:ellipsize="end"/>
-
- <TextView android:id="@android:id/text2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="8dip"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorSecondary"
- android:singleLine="true"
- android:ellipsize="end"/>
- </LinearLayout>
-</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index aaad313..d8a9e94 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -81,9 +81,6 @@
<!-- Minimum height of a row in the contact detail -->
<dimen name="detail_min_line_item_height">48dip</dimen>
- <!-- Width of height of an icon from a third-party app in the networks section of the contact card. -->
- <dimen name="detail_network_icon_size">32dip</dimen>
-
<!-- Font size for the display name in header of the contact detail page -->
<dimen name="detail_header_name_text_size">36sp</dimen>
diff --git a/res/values/donottranslate_config.xml b/res/values/donottranslate_config.xml
index a7bde88..39029d6 100644
--- a/res/values/donottranslate_config.xml
+++ b/res/values/donottranslate_config.xml
@@ -18,18 +18,6 @@
-->
<resources>
- <!-- Flag indicating whether Contacts app is allowed to import contacts from SDCard -->
- <bool name="config_allow_import_from_sdcard">true</bool>
- <!-- If true, all vcard files are imported from SDCard without asking a user.
- If not, dialog shows to let the user to select whether all vcard files are imported or not.
- If the user selects "not", then the application ask the user to select a file.-->
- <bool name="config_import_all_vcard_from_sdcard_automatically">false</bool>
- <!-- If true, vcard importer shows a dialog which asks the user whether the user wants
- to import all vcard files in SDCard or select one vcard file. If false, the dialog is
- skipped and the importer asks the user to choose one vcard file.
- If config_import_all_vcard_from_sdcard_automatically is set true, this configuration
- is ignored. -->
- <bool name="config_allow_users_select_all_vcard_import">true</bool>
<!-- Flag indicating whether Contacts app is allowed to export contacts to SDCard -->
<bool name="config_allow_export_to_sdcard">true</bool>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ada7255..6dec937 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -547,79 +547,6 @@
<!-- Action that shares visible contacts -->
<string name="share_visible_contacts">Share visible contacts</string>
- <!-- One of alternatives shown when the system allows a user to select how many vCard files
- should be imported. This message shows only when the system is certain that there's more
- than one vCard files available in the system. -->
- <string name="import_one_vcard_string">Import one vCard file</string>
-
- <!-- One of alternatives shown when the system allows a user to select how many vCard files
- should be imported. This message shows only when the system is certain that there's more
- than one vCard files available in the system. -->
- <string name="import_multiple_vcard_string">Import multiple vCard files</string>
-
- <!-- One of alternatives shown when the system allows a user to select how many vCard files
- should be imported. This message shows only when the system is certain that there's more
- than one vCard files available in the system. -->
- <string name="import_all_vcard_string">Import all vCard files</string>
-
- <!-- Dialog message shown when searching VCard data from (USB) storage [CHAR LIMIT=NONE] -->
- <string name="searching_vcard_message" product="nosdcard">Searching for vCard data in storage\u2026</string>
- <!-- Dialog message shown when searching VCard data from SD Card. [CHAR LIMIT=NONE] -->
- <string name="searching_vcard_message" product="default">Searching for vCard data on SD card\u2026</string>
-
- <!-- Dialog message shown when searching VCard data failed.
- An exact reason for the failure should [CHAR LIMIT=NONE] -->
- <string name="scanning_sdcard_failed_message" product="nosdcard">The storage couldn\'t be scanned. (Reason: \"<xliff:g id="fail_reason">%s</xliff:g>\")</string>
- <!-- Dialog message shown when searching VCard data failed.
- An exact reason for the failure should [CHAR LIMIT=NONE] -->
- <string name="scanning_sdcard_failed_message" product="default">The SD card couldn\'t be scanned. (Reason: \"<xliff:g id="fail_reason">%s</xliff:g>\")</string>
-
- <!-- The failed reason shown when Contacts app (especially vCard importer/exporter)
- emitted some I/O error. Exact reason will be appended by the system. [CHAR LIMIT=NONE] -->
- <string name="fail_reason_io_error">I/O error</string>
-
- <!-- Failure reason show when Contacts app (especially vCard importer) encountered
- low memory problem and could not proceed its import procedure. [CHAR LIMIT=NONE] -->
- <string name="fail_reason_low_memory_during_import">Not enough memory. The file may be too large.</string>
-
- <!-- The failed reason shown when vCard parser was not able to be parsed by the current vCard
- implementation. This might happen even when the input vCard is completely valid, though
- we believe it is rather rare in the actual world. [CHAR LIMIT=NONE] -->
- <string name="fail_reason_vcard_parse_error">Couldn\'t parse vCard for an unexpected reason.</string>
-
- <!-- The failed reason shown when vCard importer doesn't support the format.
- This may be shown when the vCard is corrupted [CHAR LIMIT=40] -->
- <string name="fail_reason_not_supported">The format isn\'t supported.</string>
-
- <!-- Fail reason shown when vCard importer failed to look over meta information stored in vCard file(s). -->
- <string name="fail_reason_failed_to_collect_vcard_meta_info">Couldn\'t collect meta information of given vCard file(s).</string>
-
- <!-- The failed reason shown when the import of some of vCard files failed during multiple vCard
- files import. It includes the case where all files were failed to be imported. -->
- <string name="fail_reason_failed_to_read_files">One or more files couldn\'t be imported (%s).</string>
-
- <!-- Dialog title shown when a user is asked to select vCard file. [CHAR LIMIT=25] -->
- <string name="select_vcard_title">Choose vCard file</string>
-
- <!-- The title shown when vCard importer is caching files to be imported into local temporary
- data storage. [CHAR LIMIT=40] -->
- <string name="caching_vcard_title">Caching</string>
-
- <!-- Dialog title shown when a user confirms whether he/she export Contact data. [CHAR LIMIT=32] -->
- <string name="confirm_export_title">Export contacts?</string>
-
- <!-- The failed reason shown when vCard exporter could not create a file for the vCard since
- there are too many files relevant to vCard. [CHAR LIMIT=NONE] -->
- <string name="fail_reason_too_many_vcard" product="nosdcard">Too many vCard files are in the storage.</string>
- <!-- The failed reason shown when vCard exporter could not create a file for the vCard since
- there are too many files relevant to vCard. -->
- <string name="fail_reason_too_many_vcard" product="default">Too many vCard files are on the SD card.</string>
-
- <!-- The failed reason shown when the given file name is too long for the system.
- The length limit of each file is different in each Android device, so we don't need to
- mention it here. [CHAR LIMIT=NONE] -->
- <string name="fail_reason_too_long_filename">Required filename is too long (\"<xliff:g id="filename">%s</xliff:g>\").</string>
-
<!-- Message in progress bar while exporting contact list to a file "(current number) of (total number) contacts" The order of "current number" and "total number" cannot be changed (like "total: (total number), current: (current number)")-->
<string name="exporting_contact_list_progress"><xliff:g id="current_number">%s</xliff:g> of <xliff:g id="total_number">%s</xliff:g> contacts</string>
diff --git a/src/com/android/contacts/activities/ContactEditorAccountsChangedActivity.java b/src/com/android/contacts/activities/ContactEditorAccountsChangedActivity.java
index 26a8eae..bf3b1c1 100644
--- a/src/com/android/contacts/activities/ContactEditorAccountsChangedActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorAccountsChangedActivity.java
@@ -32,8 +32,8 @@
import com.android.contacts.editor.ContactEditorUtils;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.account.AccountWithDataSet;
-import com.android.contacts.util.AccountsListAdapter;
-import com.android.contacts.util.AccountsListAdapter.AccountListFilter;
+import com.android.contacts.common.util.AccountsListAdapter;
+import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
import java.util.List;
diff --git a/src/com/android/contacts/detail/ContactDetailFragment.java b/src/com/android/contacts/detail/ContactDetailFragment.java
index e4af9b8..ccdc403 100644
--- a/src/com/android/contacts/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/detail/ContactDetailFragment.java
@@ -81,7 +81,7 @@
import com.android.contacts.common.Collapser.Collapsible;
import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.MoreContactUtils;
-import com.android.contacts.editor.SelectAccountDialogFragment;
+import com.android.contacts.common.editor.SelectAccountDialogFragment;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.model.Contact;
import com.android.contacts.model.RawContact;
@@ -107,7 +107,7 @@
import com.android.contacts.model.dataitem.StructuredNameDataItem;
import com.android.contacts.model.dataitem.StructuredPostalDataItem;
import com.android.contacts.model.dataitem.WebsiteDataItem;
-import com.android.contacts.util.AccountsListAdapter.AccountListFilter;
+import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
import com.android.contacts.util.DataStatus;
import com.android.contacts.util.DateUtils;
import com.android.contacts.util.PhoneCapabilityTester;
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 4f6aad5..13c8b33 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -81,8 +81,8 @@
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.model.account.GoogleAccountType;
-import com.android.contacts.util.AccountsListAdapter;
-import com.android.contacts.util.AccountsListAdapter.AccountListFilter;
+import com.android.contacts.common.util.AccountsListAdapter;
+import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
import com.android.contacts.util.ContactPhotoUtils;
import com.android.contacts.util.HelpUtils;
import com.google.common.collect.ImmutableList;
diff --git a/src/com/android/contacts/editor/SelectAccountDialogFragment.java b/src/com/android/contacts/editor/SelectAccountDialogFragment.java
deleted file mode 100644
index a575074..0000000
--- a/src/com/android/contacts/editor/SelectAccountDialogFragment.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2010 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
- */
-
-package com.android.contacts.editor;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.content.DialogInterface;
-import android.os.Bundle;
-
-import com.android.contacts.common.model.account.AccountWithDataSet;
-import com.android.contacts.util.AccountsListAdapter;
-import com.android.contacts.util.AccountsListAdapter.AccountListFilter;
-
-/**
- * Shows a dialog asking the user which account to chose.
- *
- * The result is passed to {@code targetFragment} passed to {@link #show}.
- */
-public final class SelectAccountDialogFragment extends DialogFragment {
- public static final String TAG = "SelectAccountDialogFragment";
-
- private static final String KEY_TITLE_RES_ID = "title_res_id";
- private static final String KEY_LIST_FILTER = "list_filter";
- private static final String KEY_EXTRA_ARGS = "extra_args";
-
- public SelectAccountDialogFragment() { // All fragments must have a public default constructor.
- }
-
- /**
- * Show the dialog.
- *
- * @param fragmentManager {@link FragmentManager}.
- * @param targetFragment {@link Fragment} that implements {@link Listener}.
- * @param titleResourceId resource ID to use as the title.
- * @param accountListFilter account filter.
- * @param extraArgs Extra arguments, which will later be passed to
- * {@link Listener#onAccountChosen}. {@code null} will be converted to
- * {@link Bundle#EMPTY}.
- */
- public static <F extends Fragment & Listener> void show(FragmentManager fragmentManager,
- F targetFragment, int titleResourceId,
- AccountListFilter accountListFilter, Bundle extraArgs) {
- final Bundle args = new Bundle();
- args.putInt(KEY_TITLE_RES_ID, titleResourceId);
- args.putSerializable(KEY_LIST_FILTER, accountListFilter);
- args.putBundle(KEY_EXTRA_ARGS, (extraArgs == null) ? Bundle.EMPTY : extraArgs);
-
- final SelectAccountDialogFragment instance = new SelectAccountDialogFragment();
- instance.setArguments(args);
- instance.setTargetFragment(targetFragment, 0);
- instance.show(fragmentManager, null);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- final Bundle args = getArguments();
-
- final AccountListFilter filter = (AccountListFilter) args.getSerializable(KEY_LIST_FILTER);
- final AccountsListAdapter accountAdapter = new AccountsListAdapter(builder.getContext(),
- filter);
-
- final DialogInterface.OnClickListener clickListener =
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
-
- onAccountSelected(accountAdapter.getItem(which));
- }
- };
-
- builder.setTitle(args.getInt(KEY_TITLE_RES_ID));
- builder.setSingleChoiceItems(accountAdapter, 0, clickListener);
- final AlertDialog result = builder.create();
- return result;
- }
-
- @Override
- public void onCancel(DialogInterface dialog) {
- super.onCancel(dialog);
- final Fragment targetFragment = getTargetFragment();
- if (targetFragment != null && targetFragment instanceof Listener) {
- final Listener target = (Listener) targetFragment;
- target.onAccountSelectorCancelled();
- }
- }
-
- /**
- * Calls {@link Listener#onAccountChosen} of {@code targetFragment}.
- */
- private void onAccountSelected(AccountWithDataSet account) {
- final Fragment targetFragment = getTargetFragment();
- if (targetFragment != null && targetFragment instanceof Listener) {
- final Listener target = (Listener) targetFragment;
- target.onAccountChosen(account, getArguments().getBundle(KEY_EXTRA_ARGS));
- }
- }
-
- public interface Listener {
- void onAccountChosen(AccountWithDataSet account, Bundle extraArgs);
- void onAccountSelectorCancelled();
- }
-}
diff --git a/src/com/android/contacts/group/GroupEditorFragment.java b/src/com/android/contacts/group/GroupEditorFragment.java
index 16b7d86..1f7074e 100644
--- a/src/com/android/contacts/group/GroupEditorFragment.java
+++ b/src/com/android/contacts/group/GroupEditorFragment.java
@@ -66,10 +66,10 @@
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountWithDataSet;
-import com.android.contacts.editor.SelectAccountDialogFragment;
+import com.android.contacts.common.editor.SelectAccountDialogFragment;
import com.android.contacts.group.SuggestedMemberListAdapter.SuggestedMember;
import com.android.contacts.common.model.AccountTypeManager;
-import com.android.contacts.util.AccountsListAdapter.AccountListFilter;
+import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
import com.android.contacts.util.ViewUtil;
import com.google.common.base.Objects;
diff --git a/src/com/android/contacts/interactions/ImportExportDialogFragment.java b/src/com/android/contacts/interactions/ImportExportDialogFragment.java
index b360271..f103fca 100644
--- a/src/com/android/contacts/interactions/ImportExportDialogFragment.java
+++ b/src/com/android/contacts/interactions/ImportExportDialogFragment.java
@@ -38,11 +38,11 @@
import android.widget.Toast;
import com.android.contacts.R;
-import com.android.contacts.editor.SelectAccountDialogFragment;
+import com.android.contacts.common.editor.SelectAccountDialogFragment;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.util.AccountSelectionUtil;
-import com.android.contacts.util.AccountsListAdapter.AccountListFilter;
+import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
import com.android.contacts.common.vcard.ExportVCardActivity;
import com.android.contacts.common.vcard.VCardCommonArguments;
diff --git a/src/com/android/contacts/util/AccountsListAdapter.java b/src/com/android/contacts/util/AccountsListAdapter.java
deleted file mode 100644
index a2891a8..0000000
--- a/src/com/android/contacts/util/AccountsListAdapter.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.contacts.util;
-
-import android.content.Context;
-import android.text.TextUtils.TruncateAt;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.android.contacts.R;
-import com.android.contacts.common.model.AccountTypeManager;
-import com.android.contacts.common.model.account.AccountType;
-import com.android.contacts.common.model.account.AccountWithDataSet;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * List-Adapter for Account selection
- */
-public final class AccountsListAdapter extends BaseAdapter {
- private final LayoutInflater mInflater;
- private final List<AccountWithDataSet> mAccounts;
- private final AccountTypeManager mAccountTypes;
- private final Context mContext;
-
- /**
- * Filters that affect the list of accounts that is displayed by this adapter.
- */
- public enum AccountListFilter {
- ALL_ACCOUNTS, // All read-only and writable accounts
- ACCOUNTS_CONTACT_WRITABLE, // Only where the account type is contact writable
- ACCOUNTS_GROUP_WRITABLE // Only accounts where the account type is group writable
- }
-
- public AccountsListAdapter(Context context, AccountListFilter accountListFilter) {
- this(context, accountListFilter, null);
- }
-
- /**
- * @param currentAccount the Account currently selected by the user, which should come
- * first in the list. Can be null.
- */
- public AccountsListAdapter(Context context, AccountListFilter accountListFilter,
- AccountWithDataSet currentAccount) {
- mContext = context;
- mAccountTypes = AccountTypeManager.getInstance(context);
- mAccounts = getAccounts(accountListFilter);
- if (currentAccount != null
- && !mAccounts.isEmpty()
- && !mAccounts.get(0).equals(currentAccount)
- && mAccounts.remove(currentAccount)) {
- mAccounts.add(0, currentAccount);
- }
- mInflater = LayoutInflater.from(context);
- }
-
- private List<AccountWithDataSet> getAccounts(AccountListFilter accountListFilter) {
- if (accountListFilter == AccountListFilter.ACCOUNTS_GROUP_WRITABLE) {
- return new ArrayList<AccountWithDataSet>(mAccountTypes.getGroupWritableAccounts());
- }
- return new ArrayList<AccountWithDataSet>(mAccountTypes.getAccounts(
- accountListFilter == AccountListFilter.ACCOUNTS_CONTACT_WRITABLE));
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- final View resultView = convertView != null ? convertView
- : mInflater.inflate(R.layout.account_selector_list_item, parent, false);
-
- final TextView text1 = (TextView) resultView.findViewById(android.R.id.text1);
- final TextView text2 = (TextView) resultView.findViewById(android.R.id.text2);
- final ImageView icon = (ImageView) resultView.findViewById(android.R.id.icon);
-
- final AccountWithDataSet account = mAccounts.get(position);
- final AccountType accountType = mAccountTypes.getAccountType(account.type, account.dataSet);
-
- text1.setText(accountType.getDisplayLabel(mContext));
-
- // For email addresses, we don't want to truncate at end, which might cut off the domain
- // name.
- text2.setText(account.name);
- text2.setEllipsize(TruncateAt.MIDDLE);
-
- icon.setImageDrawable(accountType.getDisplayIcon(mContext));
-
- return resultView;
- }
-
- @Override
- public int getCount() {
- return mAccounts.size();
- }
-
- @Override
- public AccountWithDataSet getItem(int position) {
- return mAccounts.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-}
-