Make SIM import screen an activity
This fixes an accessibility bug where the toolbar navigation icon was
announced instead of the title when the screen is displayed
test
* manually verify that SIM import works as previously when launched from
settings and from assistant.
* manually verify that activity label is announced instead of navigation
icon
Bug 32947074
Change-Id: I1116d626f13842ad78e287c98dd3a051796b1f5f
diff --git a/AndroidManifest_common.xml b/AndroidManifest_common.xml
index a41bedd..b2a3c88 100644
--- a/AndroidManifest_common.xml
+++ b/AndroidManifest_common.xml
@@ -441,6 +441,11 @@
<activity android:name=".common.vcard.ShareVCardActivity"
android:theme="@style/BackgroundOnlyTheme" />
+ <activity android:name=".activities.SimImportActivity"
+ android:theme="@style/PeopleThemeAppCompat.FullScreenDialog.SimImportActivity"
+ android:label="@string/sim_import_title" />
+
+
<service
android:name=".common.vcard.VCardService"
android:exported="false" />
diff --git a/res/layout/sim_import_activity.xml b/res/layout/sim_import_activity.xml
new file mode 100644
index 0000000..ac8a9c4
--- /dev/null
+++ b/res/layout/sim_import_activity.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a9f1dc4..a544c08 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1879,11 +1879,11 @@
<!-- Toast shown on settings screen when importing from SIM completes with an error -->
<string name="sim_import_failed_toast">Failed to import SIM contacts</string>
- <!-- Title of SIM import dialog for accessibility; this isn't displayed but is announced
- by talkback when the window is shown -->
- <string name="sim_import_dialog_title">Select contacts to import</string>
+ <!-- Title of the SIM import activity; this isn't displayed but is announced by talkback
+ when the window is first opened [CHAR LIMIT=40] -->
+ <string name="sim_import_title">Import from SIM</string>
- <!-- Content description of the cancel navigation icon shown in SIM import dialog toolbar -->
+ <!-- Content description of the cancel navigation icon shown in SIM import screen toolbar -->
<string name="sim_import_cancel_content_description">Cancel import</string>
<!-- Alert for letting user know that their device auto-sync setting is turned off,
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0d9e44f..7f0191e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -38,7 +38,9 @@
<item name="android:listViewStyle">@style/ListViewStyle</item>
<!-- We need to use a light ripple behind ActionBar items in order for them to
be visible when using some of the darker ActionBar tints -->
- <item name="android:actionBarItemBackground">@drawable/item_background_material_borderless_dark</item>
+ <item name="android:actionBarItemBackground">
+ @drawable/item_background_material_borderless_dark
+ </item>
</style>
<style name="PeopleTheme" parent="@android:style/Theme.Material.Light">
@@ -208,7 +210,7 @@
</style>
<style name="ContactsActionBarStyleAppCompat"
- parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
+ parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<!-- Styles that require AppCompat compatibility, remember to update both sets -->
<item name="android:background">@color/actionbar_background_color</item>
<item name="background">@color/actionbar_background_color</item>
@@ -252,7 +254,7 @@
<!-- Text in the action bar at the top of the screen -->
<style name="ContactsActionBarTitleText"
- parent="@android:style/TextAppearance.Material.Widget.ActionBar.Title">
+ parent="@android:style/TextAppearance.Material.Widget.ActionBar.Title">
<item name="android:textSize">20dp</item>
<item name="android:textColor">@color/actionbar_text_color</item>
</style>
@@ -268,7 +270,7 @@
<!-- Action bar overflow menu icon. -->
<style name="ContactsActionBarOverflowQP"
- parent="Widget.AppCompat.Light.ActionButton.Overflow">
+ parent="Widget.AppCompat.Light.ActionButton.Overflow">
<item name="android:src">@drawable/ic_more_vert</item>
<item name="android:tint">@color/action_bar_button_text_color</item>
</style>
@@ -282,7 +284,7 @@
<item name="android:listSelector">?android:attr/listChoiceBackgroundIndicator</item>
</style>
- <style name="ContactPickerTheme" parent="PeopleActivityTheme" >
+ <style name="ContactPickerTheme" parent="PeopleActivityTheme">
</style>
<style name="ContactsPreferencesTheme" parent="@style/PeopleThemeAppCompat">
@@ -441,6 +443,7 @@
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textAllCaps">true</item>
</style>
+
<style name="DirectoryHeader">
<item name="android:background">@android:color/transparent</item>
</style>
@@ -549,9 +552,16 @@
<style name="PeopleThemeAppCompat.FullScreenDialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
- <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
+ <item name="windowActionBar">false</item>
<item name="android:listSelector">?android:attr/listChoiceBackgroundIndicator</item>
<item name="android:windowAnimationStyle">@style/FullScreenDialogAnimationStyle</item>
</style>
+
+ <style name="PeopleThemeAppCompat.FullScreenDialog.SimImportActivity">
+ <!-- This is necessary because the window is partially transparent during the enter
+ and exit animations -->
+ <item name="android:windowIsTranslucent">true</item>
+ <item name="android:statusBarColor">@color/contextual_selection_bar_status_bar_color</item>
+ </style>
</resources>
diff --git a/src/com/android/contacts/SimImportFragment.java b/src/com/android/contacts/SimImportFragment.java
index 5f5de3e..c8a9b9a 100644
--- a/src/com/android/contacts/SimImportFragment.java
+++ b/src/com/android/contacts/SimImportFragment.java
@@ -15,8 +15,8 @@
*/
package com.android.contacts;
-import android.app.Dialog;
-import android.app.DialogFragment;
+import android.app.Activity;
+import android.app.Fragment;
import android.app.LoaderManager;
import android.content.AsyncTaskLoader;
import android.content.Context;
@@ -59,13 +59,12 @@
* Dialog that presents a list of contacts from a SIM card that can be imported into a selected
* account
*/
-public class SimImportFragment extends DialogFragment
+public class SimImportFragment extends Fragment
implements LoaderManager.LoaderCallbacks<SimImportFragment.LoaderResult>,
AdapterView.OnItemClickListener, AbsListView.OnScrollListener {
private static final String KEY_SUFFIX_SELECTED_IDS = "_selectedIds";
private static final String ARG_SUBSCRIPTION_ID = "subscriptionId";
- private static final String TAG = "SimImportFragment";
private ContactsPreferences mPreferences;
private AccountTypeManager mAccountTypeManager;
@@ -86,7 +85,6 @@
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setStyle(STYLE_NORMAL, R.style.PeopleThemeAppCompat_FullScreenDialog);
mPreferences = new ContactsPreferences(getContext());
mAccountTypeManager = AccountTypeManager.getInstance(getActivity());
mAdapter = new SimContactAdapter(getActivity());
@@ -97,15 +95,6 @@
}
@Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- Dialog dialog = super.onCreateDialog(savedInstanceState);
- // Set the title for accessibility. It isn't displayed but will get announced when the
- // window is shown
- dialog.setTitle(R.string.sim_import_dialog_title);
- return dialog;
- }
-
- @Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getLoaderManager().initLoader(0, null, this);
@@ -113,7 +102,8 @@
@Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_sim_import, container, false);
mAccountHeaderContainer = view.findViewById(R.id.account_header_container);
@@ -151,7 +141,8 @@
public void onClick(View v) {
importCurrentSelections();
// Do we wait for import to finish?
- dismiss();
+ getActivity().setResult(Activity.RESULT_OK);
+ getActivity().finish();
}
});
@@ -159,7 +150,8 @@
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- dismiss();
+ getActivity().setResult(Activity.RESULT_CANCELED);
+ getActivity().finish();
}
});
diff --git a/src/com/android/contacts/activities/SimImportActivity.java b/src/com/android/contacts/activities/SimImportActivity.java
new file mode 100644
index 0000000..391cd8b
--- /dev/null
+++ b/src/com/android/contacts/activities/SimImportActivity.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2016 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.activities;
+
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.os.Bundle;
+
+import com.android.contacts.AppCompatContactsActivity;
+import com.android.contacts.R;
+import com.android.contacts.SimImportFragment;
+import com.android.contacts.common.model.SimCard;
+
+/**
+ * Host activity for SimImportFragment
+ *
+ * Initially SimImportFragment was a DialogFragment but there were accessibility issues with
+ * that so it was changed to an activity
+ */
+public class SimImportActivity extends AppCompatContactsActivity {
+
+ public static final String EXTRA_SUBSCRIPTION_ID = "extraSubscriptionId";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.sim_import_activity);
+ final FragmentManager fragmentManager = getFragmentManager();
+ Fragment fragment = fragmentManager.findFragmentByTag("SimImport");
+ if (fragment == null) {
+ fragment = SimImportFragment.newInstance(getIntent().getIntExtra(EXTRA_SUBSCRIPTION_ID,
+ SimCard.NO_SUBSCRIPTION_ID));
+ fragmentManager.beginTransaction().add(R.id.root, fragment, "SimImport").commit();
+ }
+ }
+}
diff --git a/src/com/android/contacts/common/interactions/ImportDialogFragment.java b/src/com/android/contacts/common/interactions/ImportDialogFragment.java
index a748b81..1b2c98d 100644
--- a/src/com/android/contacts/common/interactions/ImportDialogFragment.java
+++ b/src/com/android/contacts/common/interactions/ImportDialogFragment.java
@@ -23,6 +23,7 @@
import android.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.TextUtils;
@@ -34,6 +35,7 @@
import android.widget.TextView;
import com.android.contacts.SimImportFragment;
+import com.android.contacts.activities.SimImportActivity;
import com.android.contacts.common.R;
import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
@@ -231,8 +233,8 @@
}
private void handleSimImportRequest(SimCard sim) {
- SimImportFragment.newInstance(sim.getSubscriptionId()).show(getFragmentManager(),
- "SimImport");
+ startActivity(new Intent(getActivity(), SimImportActivity.class)
+ .putExtra(SimImportActivity.EXTRA_SUBSCRIPTION_ID, sim.getSubscriptionId()));
}
/**