Merge "Import translations. DO NOT MERGE" into ub-contactsdialer-i-dev
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 34b4f40..52065c4 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -69,7 +69,6 @@
import com.android.contacts.group.GroupMembersFragment;
import com.android.contacts.group.GroupNameEditDialogFragment;
import com.android.contacts.group.GroupUtil;
-import com.android.contacts.interactions.ContactDeletionInteraction;
import com.android.contacts.list.AccountFilterActivity;
import com.android.contacts.list.ContactListFilter;
import com.android.contacts.list.ContactListFilterController;
@@ -98,6 +97,7 @@
import com.android.contactsbind.FeatureHighlightHelper;
import com.android.contactsbind.HelpUtils;
import com.android.contactsbind.ObjectFactory;
+
import com.google.common.util.concurrent.Futures;
import java.util.Collections;
@@ -130,6 +130,7 @@
public static final String TAG_ASSISTANT = "contacts-assistant";
public static final String TAG_SECOND_LEVEL = "second-level";
public static final String TAG_THIRD_LEVEL = "third-level";
+ public static final String TAG_ASSISTANT_HELPER = "assistant-helper";
public static final String TAG_DUPLICATES = "DuplicatesFragment";
public static final String TAG_DUPLICATES_UTIL = "DuplicatesUtilFragment";
@@ -821,10 +822,11 @@
}
private void onBackPressedAssistantView() {
- if (!popThirdLevel()) {
+ if (!isInThirdLevel()) {
switchToAllContacts();
} else {
setDrawerLockMode(/* enabled */ true);
+ super.onBackPressed();
}
}
@@ -974,6 +976,7 @@
final FragmentManager fragmentManager = getFragmentManager();
final FragmentTransaction transaction = fragmentManager.beginTransaction();
+ popSecondLevel();
if (isGroupView()) {
mMembersFragment = GroupMembersFragment.newInstance(mGroupUri);
transaction.replace(
@@ -998,9 +1001,7 @@
}
public void switchToAllContacts() {
- if (isInSecondLevel()) {
- popSecondLevel();
- }
+ popSecondLevel();
mShouldSwitchToAllContacts = false;
mCurrentView = ContactsView.ALL_CONTACTS;
mDrawerFragment.setNavigationItemChecked(ContactsView.ALL_CONTACTS);
@@ -1018,18 +1019,6 @@
mContactListFilterController, AppCompatActivity.RESULT_OK, intent);
}
- private boolean popThirdLevel() {
- return getFragmentManager().popBackStackImmediate(
- TAG_THIRD_LEVEL, FragmentManager.POP_BACK_STACK_INCLUSIVE);
- }
-
- private void popSecondLevel() {
- getFragmentManager().popBackStackImmediate(
- TAG_SECOND_LEVEL, FragmentManager.POP_BACK_STACK_INCLUSIVE);
- mMembersFragment = null;
- resetToolBarStatusBarColor();
- }
-
// Reset toolbar and status bar color to Contacts theme color.
private void resetToolBarStatusBarColor() {
findViewById(R.id.toolbar_frame).setBackgroundColor(
@@ -1223,7 +1212,33 @@
}
public boolean isInSecondLevel() {
- return isGroupView() || isAssistantView();
+ return isLastBackStackTag(TAG_SECOND_LEVEL);
+ }
+
+ private boolean isInThirdLevel() {
+ return isLastBackStackTag(TAG_THIRD_LEVEL);
+ }
+
+ private boolean isLastBackStackTag(String tag) {
+ final int count = getFragmentManager().getBackStackEntryCount();
+ if (count > 0) {
+ final FragmentManager.BackStackEntry last =
+ getFragmentManager().getBackStackEntryAt(count - 1);
+ if (tag == null) {
+ return last.getName() == null;
+ }
+ return tag.equals(last.getName());
+ }
+ return false;
+ }
+
+ private void popSecondLevel() {
+ getFragmentManager().popBackStackImmediate(
+ TAG_ASSISTANT_HELPER, FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ getFragmentManager().popBackStackImmediate(
+ TAG_SECOND_LEVEL, FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ mMembersFragment = null;
+ resetToolBarStatusBarColor();
}
public void closeDrawer() {
diff --git a/src/com/android/contacts/util/concurrent/ListenableFutureLoader.java b/src/com/android/contacts/util/concurrent/ListenableFutureLoader.java
index 441ca68..67d5259 100644
--- a/src/com/android/contacts/util/concurrent/ListenableFutureLoader.java
+++ b/src/com/android/contacts/util/concurrent/ListenableFutureLoader.java
@@ -107,7 +107,7 @@
Log.i(TAG, "Loading cancelled", t);
rollbackContentChanged();
} else {
- Log.e(TAG, "Failed to load accounts", t);
+ Log.e(TAG, "Loading failed", t);
}
}
}, mUiExecutor);
diff --git a/tests/src/com/android/contacts/activities/SimImportActivityTest.java b/tests/src/com/android/contacts/activities/SimImportActivityTest.java
index aa52c08..ae8fb78 100644
--- a/tests/src/com/android/contacts/activities/SimImportActivityTest.java
+++ b/tests/src/com/android/contacts/activities/SimImportActivityTest.java
@@ -21,8 +21,9 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
import android.annotation.TargetApi;
import android.app.Activity;
@@ -41,7 +42,6 @@
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.LargeTest;
import android.support.test.filters.SdkSuppress;
-import android.support.test.filters.Suppress;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
@@ -53,7 +53,6 @@
import com.android.contacts.SimImportService;
import com.android.contacts.database.SimContactDao;
import com.android.contacts.database.SimContactDaoImpl;
-import com.android.contacts.model.AccountTypeManager;
import com.android.contacts.model.SimCard;
import com.android.contacts.model.SimContact;
import com.android.contacts.model.account.AccountWithDataSet;
@@ -74,6 +73,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.Collections;
import java.util.concurrent.TimeUnit;
/**
@@ -82,14 +82,14 @@
* These should probably be converted to espresso tests because espresso does a better job of
* waiting for the app to be idle once espresso library is added
*/
-@Suppress
+//@Suppress
@LargeTest
@RunWith(AndroidJUnit4.class)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.M)
@TargetApi(Build.VERSION_CODES.M)
public class SimImportActivityTest {
- public static final int TIMEOUT = 3000;
+ public static final int TIMEOUT = 100000;
private Context mContext;
private UiDevice mDevice;
private Instrumentation mInstrumentation;
@@ -116,7 +116,6 @@
public void tearDown() throws Exception {
SimContactDao.setFactoryForTest(SimContactDao.DEFAULT_FACTORY);
mAccountHelper.cleanup();
- AccountTypeManager.setInstanceForTest(null);
if (mActivity != null) {
mActivity.finish();
mInstrumentation.waitForIdleSync();
@@ -219,9 +218,6 @@
*/
@Test
public void selectionsAreImportedAndDisabledOnSubsequentImports() throws Exception {
- // Clear out the instance so that it will have the most recent accounts when reloaded
- AccountTypeManager.setInstanceForTest(null);
-
final AccountWithDataSet targetAccount = mAccountHelper.addTestAccount(
mAccountHelper.generateAccountName("SimImportActivity0_targetAccount_"));
@@ -249,7 +245,10 @@
final SimContactDaoImpl spy = spy(new SimContactDaoImpl(
mContext, mockResolver,
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE)));
- when(spy.canReadSimContacts()).thenReturn(true);
+ final SimCard sim = someSimCard();
+ doReturn(true).when(spy).canReadSimContacts();
+ doReturn(Collections.singletonList(sim)).when(spy).getSimCards();
+ doReturn(sim).when(spy).getSimBySubscriptionId(anyInt());
return spy;
}
});