Remove OnContactsUnavailableActionListener
- Also add back updateButtonVisibility(View.VISIBLE) which was
deleted in ag/1338636 by mistake.
Bug: 30944495
Test: manual
- Add account and import contacts from no contacts view
Change-Id: I98bd002474ec4e656422473f9954834fc6c21f46
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 60400fd..0d29e06 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -54,7 +54,6 @@
import com.android.contacts.R;
import com.android.contacts.common.Experiments;
import com.android.contacts.common.activity.RequestPermissionsActivity;
-import com.android.contacts.common.interactions.ImportExportDialogFragment;
import com.android.contacts.common.list.ContactListFilter;
import com.android.contacts.common.list.ProviderStatusWatcher;
import com.android.contacts.common.list.ProviderStatusWatcher.ProviderStatusListener;
@@ -66,7 +65,6 @@
import com.android.contacts.common.util.Constants;
import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.common.widget.FloatingActionButtonController;
-import com.android.contacts.editor.EditorIntents;
import com.android.contacts.group.GroupMembersFragment;
import com.android.contacts.group.GroupMetaData;
import com.android.contacts.group.GroupUtil;
@@ -74,7 +72,6 @@
import com.android.contacts.list.ContactsRequest;
import com.android.contacts.list.ContactsUnavailableFragment;
import com.android.contacts.list.DefaultContactBrowseListFragment;
-import com.android.contacts.list.OnContactsUnavailableActionListener;
import com.android.contacts.quickcontact.QuickContactActivity;
import com.android.contacts.util.SyncUtil;
import com.android.contactsbind.FeatureHighlightHelper;
@@ -200,26 +197,6 @@
return (mProviderStatus != null) && mProviderStatus.equals(ProviderStatus.STATUS_NORMAL);
}
- /**
- * Initialize fragments that are (or may not be) in the layout.
- *
- * For the fragments that are in the layout, we initialize them in
- * {@link #createViewsAndFragments()} after inflating the layout.
- *
- * However, the {@link ContactsUnavailableFragment} is a special fragment which may not
- * be in the layout, so we have to do the initialization here.
- *
- * The ContactsUnavailableFragment is always created at runtime.
- */
- @Override
- public void onAttachFragment(Fragment fragment) {
- if (fragment instanceof ContactsUnavailableFragment) {
- mContactsUnavailableFragment = (ContactsUnavailableFragment)fragment;
- mContactsUnavailableFragment.setOnContactsUnavailableActionListener(
- new ContactsUnavailableFragmentListener());
- }
- }
-
@Override
protected void onCreate(Bundle savedState) {
if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
@@ -554,8 +531,6 @@
}
if (mContactsUnavailableFragment == null) {
mContactsUnavailableFragment = new ContactsUnavailableFragment();
- mContactsUnavailableFragment.setOnContactsUnavailableActionListener(
- new ContactsUnavailableFragmentListener());
transaction.add(R.id.contacts_list_container, mContactsUnavailableFragment,
TAG_UNAVAILABLE);
}
@@ -589,28 +564,6 @@
return !allAccounts.get(0).isLocalAccount();
}
- private class ContactsUnavailableFragmentListener
- implements OnContactsUnavailableActionListener {
- ContactsUnavailableFragmentListener() {}
-
- @Override
- public void onCreateNewContactAction() {
- ImplicitIntentsUtil.startActivityInApp(PeopleActivity.this,
- EditorIntents.createCompactInsertContactIntent(PeopleActivity.this));
- }
-
- @Override
- public void onAddAccountAction() {
- final Intent intent = ImplicitIntentsUtil.getIntentForAddingGoogleAccount();
- ImplicitIntentsUtil.startActivityOutsideApp(PeopleActivity.this, intent);
- }
-
- @Override
- public void onImportContactsFromFileAction() {
- showImportExportDialogFragment();
- }
- }
-
private void invalidateOptionsMenuIfNeeded() {
if (mAllFragment != null
&& mAllFragment.getOptionsMenuContactsAvailable() != areContactsAvailable()) {
@@ -618,11 +571,6 @@
}
}
- private void showImportExportDialogFragment(){
- ImportExportDialogFragment.show(getFragmentManager(), areContactsAvailable(),
- PeopleActivity.class, ImportExportDialogFragment.EXPORT_MODE_ALL_CONTACTS);
- }
-
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Bring up the search UI if the user starts typing
diff --git a/src/com/android/contacts/list/ContactsUnavailableFragment.java b/src/com/android/contacts/list/ContactsUnavailableFragment.java
index aa08a32..c567dd2 100644
--- a/src/com/android/contacts/list/ContactsUnavailableFragment.java
+++ b/src/com/android/contacts/list/ContactsUnavailableFragment.java
@@ -17,9 +17,11 @@
import android.app.Fragment;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.PorterDuff;
import android.os.Bundle;
+import android.provider.ContactsContract.ProviderStatus;
import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -34,6 +36,8 @@
import com.android.contacts.R;
import com.android.contacts.common.compat.ProviderStatusCompat;
+import com.android.contacts.common.interactions.ImportExportDialogFragment;
+import com.android.contacts.common.util.ImplicitIntentsUtil;
/**
* Fragment shown when contacts are unavailable. It contains provider status
@@ -48,18 +52,10 @@
private Button mImportContactsButton;
private ProgressBar mProgress;
private View mButtonsContainer;
- private int mNoContactsMsgResId = -1;
-
- private OnContactsUnavailableActionListener mListener;
private Integer mProviderStatus;
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.contacts_unavailable_fragment, null);
@@ -99,11 +95,6 @@
return mView;
}
- public void setOnContactsUnavailableActionListener(
- OnContactsUnavailableActionListener listener) {
- mListener = listener;
- }
-
public void updateStatus(int providerStatus) {
mProviderStatus = providerStatus;
if (mView == null) {
@@ -123,6 +114,7 @@
* Update views in the fragment when provider status is empty.
*/
private void updateViewsForEmptyStatus() {
+ updateButtonVisibility(View.VISIBLE);
mProgress.setVisibility(View.GONE);
}
@@ -135,7 +127,7 @@
mMessageView.setText(resId);
mMessageView.setVisibility(View.VISIBLE);
mImageView.setVisibility(View.GONE);
- updateButtonVisibilty(View.GONE);
+ updateButtonVisibility(View.GONE);
mProgress.setVisibility(View.VISIBLE);
final ViewGroup.MarginLayoutParams layoutParams =
@@ -148,20 +140,25 @@
@Override
public void onClick(View v) {
- if (mListener == null) {
- return;
- }
switch (v.getId()) {
case R.id.add_account_button:
- mListener.onAddAccountAction();
+ final Intent intent = ImplicitIntentsUtil.getIntentForAddingGoogleAccount();
+ ImplicitIntentsUtil.startActivityOutsideApp(getActivity(), intent);
break;
case R.id.import_contacts_button:
- mListener.onImportContactsFromFileAction();
+ ImportExportDialogFragment.show(getFragmentManager(), areContactsAvailable(),
+ getActivity().getClass(),
+ ImportExportDialogFragment.EXPORT_MODE_ALL_CONTACTS);
break;
}
}
- private void updateButtonVisibilty(int visibility) {
+ private boolean areContactsAvailable() {
+ return (mProviderStatus != null) && mProviderStatus.equals(ProviderStatus.STATUS_NORMAL);
+ }
+
+
+ private void updateButtonVisibility(int visibility) {
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
mAddAccountButton.setVisibility(visibility);
mImportContactsButton.setVisibility(visibility);
diff --git a/src/com/android/contacts/list/OnContactsUnavailableActionListener.java b/src/com/android/contacts/list/OnContactsUnavailableActionListener.java
deleted file mode 100644
index cc381e4..0000000
--- a/src/com/android/contacts/list/OnContactsUnavailableActionListener.java
+++ /dev/null
@@ -1,37 +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.list;
-
-/**
- * Action callbacks that can be sent by the "contacts unavailable" fragment.
- */
-public interface OnContactsUnavailableActionListener {
-
- /**
- * Creates a new contact.
- */
- void onCreateNewContactAction();
-
- /**
- * Initiates addition of a contacts account.
- */
- void onAddAccountAction();
-
- /**
- * Initiates contact import from a file.
- */
- void onImportContactsFromFileAction();
-}