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/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);