summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java49
-rw-r--r--src/com/android/dialer/calllog/VisualVoicemailCallLogFragment.java87
-rw-r--r--src/com/android/dialer/list/ListsFragment.java3
3 files changed, 99 insertions, 40 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index fa6deaf55..41ff7d311 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -16,8 +16,6 @@
package com.android.dialer.calllog;
-import static android.Manifest.permission.READ_CALL_LOG;
-
import android.app.Activity;
import android.app.Fragment;
import android.app.KeyguardManager;
@@ -32,7 +30,7 @@ import android.os.Message;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
-import android.provider.VoicemailContract.Status;
+import android.support.annotation.Nullable;
import android.support.v13.app.FragmentCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@@ -43,14 +41,14 @@ import android.view.ViewGroup;
import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.dialer.R;
-import com.android.dialer.filterednumber.FilteredNumbersUtil;
-import com.android.dialer.list.ListsFragment;
import com.android.dialer.util.EmptyLoader;
import com.android.dialer.voicemail.VoicemailPlaybackPresenter;
import com.android.dialer.widget.EmptyContentView;
import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClickedListener;
import com.android.dialerbind.ObjectFactory;
+import static android.Manifest.permission.READ_CALL_LOG;
+
/**
* Displays a list of call log entries. To filter for a particular kind of call
* (all, missed or voicemails), specify it in the constructor.
@@ -84,11 +82,8 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
private LinearLayoutManager mLayoutManager;
private CallLogAdapter mAdapter;
private CallLogQueryHandler mCallLogQueryHandler;
- private VoicemailPlaybackPresenter mVoicemailPlaybackPresenter;
private boolean mScrollToTop;
- /** Whether there is at least one voicemail source installed. */
- private boolean mVoicemailSourcesAvailable = false;
private EmptyContentView mEmptyListView;
private KeyguardManager mKeyguardManager;
@@ -111,7 +106,7 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
private final Handler mHandler = new Handler();
- private class CustomContentObserver extends ContentObserver {
+ protected class CustomContentObserver extends ContentObserver {
public CustomContentObserver() {
super(mHandler);
}
@@ -124,7 +119,6 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
// See issue 6363009
private final ContentObserver mCallLogObserver = new CustomContentObserver();
private final ContentObserver mContactsObserver = new CustomContentObserver();
- private final ContentObserver mVoicemailStatusObserver = new CustomContentObserver();
private boolean mRefreshDataRequired = true;
private boolean mHasReadCallLogPermission = false;
@@ -210,13 +204,7 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
resolver.registerContentObserver(CallLog.CONTENT_URI, true, mCallLogObserver);
resolver.registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true,
mContactsObserver);
- resolver.registerContentObserver(Status.CONTENT_URI, true, mVoicemailStatusObserver);
setHasOptionsMenu(true);
-
- if (mCallTypeFilter == Calls.VOICEMAIL_TYPE) {
- mVoicemailPlaybackPresenter = VoicemailPlaybackPresenter
- .getInstance(activity, state);
- }
}
/** Called by the CallLogQueryHandler when the list of calls has been fetched or updated. */
@@ -292,7 +280,12 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
View view = inflater.inflate(R.layout.call_log_fragment, container, false);
+ setupView(view, null);
+ return view;
+ }
+ protected void setupView(
+ View view, @Nullable VoicemailPlaybackPresenter voicemailPlaybackPresenter) {
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(getActivity());
@@ -306,11 +299,10 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
getActivity(),
this,
new ContactInfoHelper(getActivity(), currentCountryIso),
- mVoicemailPlaybackPresenter,
+ voicemailPlaybackPresenter,
mIsCallLogActivity);
mRecyclerView.setAdapter(mAdapter);
fetchCalls();
- return view;
}
@Override
@@ -348,19 +340,11 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
mAdapter.onResume();
rescheduleDisplayUpdate();
-
- if (mVoicemailPlaybackPresenter != null) {
- mVoicemailPlaybackPresenter.onResume();
- }
}
@Override
public void onPause() {
cancelDisplayUpdate();
-
- if (mVoicemailPlaybackPresenter != null) {
- mVoicemailPlaybackPresenter.onPause();
- }
mAdapter.onPause();
super.onPause();
}
@@ -376,13 +360,8 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
public void onDestroy() {
mAdapter.changeCursor(null);
- if (mVoicemailPlaybackPresenter != null) {
- mVoicemailPlaybackPresenter.onDestroy();
- }
-
getActivity().getContentResolver().unregisterContentObserver(mCallLogObserver);
getActivity().getContentResolver().unregisterContentObserver(mContactsObserver);
- getActivity().getContentResolver().unregisterContentObserver(mVoicemailStatusObserver);
super.onDestroy();
}
@@ -394,19 +373,11 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
outState.putLong(KEY_DATE_LIMIT, mDateLimit);
mAdapter.onSaveInstanceState(outState);
-
- if (mVoicemailPlaybackPresenter != null) {
- mVoicemailPlaybackPresenter.onSaveInstanceState(outState);
- }
}
@Override
public void fetchCalls() {
mCallLogQueryHandler.fetchCalls(mCallTypeFilter, mDateLimit);
-
- if (mVoicemailPlaybackPresenter != null) {
- ((ListsFragment) getParentFragment()).updateTabUnreadCounts();
- }
}
private void updateEmptyMessage(int filterType) {
diff --git a/src/com/android/dialer/calllog/VisualVoicemailCallLogFragment.java b/src/com/android/dialer/calllog/VisualVoicemailCallLogFragment.java
new file mode 100644
index 000000000..311ff7dc5
--- /dev/null
+++ b/src/com/android/dialer/calllog/VisualVoicemailCallLogFragment.java
@@ -0,0 +1,87 @@
+/*
+ * 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.dialer.calllog;
+
+import android.database.ContentObserver;
+import android.os.Bundle;
+import android.provider.CallLog;
+import android.provider.VoicemailContract;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.dialer.R;
+import com.android.dialer.list.ListsFragment;
+import com.android.dialer.voicemail.VoicemailPlaybackPresenter;
+
+public class VisualVoicemailCallLogFragment extends CallLogFragment {
+
+ private VoicemailPlaybackPresenter mVoicemailPlaybackPresenter;
+ private final ContentObserver mVoicemailStatusObserver = new CustomContentObserver();
+
+ public VisualVoicemailCallLogFragment() {
+ super(CallLog.Calls.VOICEMAIL_TYPE);
+ }
+
+ @Override
+ public void onCreate(Bundle state) {
+ super.onCreate(state);
+ mVoicemailPlaybackPresenter = VoicemailPlaybackPresenter.getInstance(getActivity(), state);
+ getActivity().getContentResolver().registerContentObserver(
+ VoicemailContract.Status.CONTENT_URI, true, mVoicemailStatusObserver);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
+ View view = inflater.inflate(R.layout.call_log_fragment, container, false);
+ setupView(view, mVoicemailPlaybackPresenter);
+ return view;
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mVoicemailPlaybackPresenter.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ mVoicemailPlaybackPresenter.onPause();
+ super.onPause();
+ }
+
+ @Override
+ public void onDestroy() {
+ mVoicemailPlaybackPresenter.onDestroy();
+ getActivity().getContentResolver().unregisterContentObserver(mVoicemailStatusObserver);
+ super.onDestroy();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mVoicemailPlaybackPresenter.onSaveInstanceState(outState);
+ }
+
+ @Override
+ public void fetchCalls() {
+ super.fetchCalls();
+ ((ListsFragment) getParentFragment()).updateTabUnreadCounts();
+ }
+}
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java
index 529449830..d5caa1a2e 100644
--- a/src/com/android/dialer/list/ListsFragment.java
+++ b/src/com/android/dialer/list/ListsFragment.java
@@ -37,6 +37,7 @@ import com.android.dialer.DialtactsActivity;
import com.android.dialer.R;
import com.android.dialer.calllog.CallLogFragment;
import com.android.dialer.calllog.CallLogQueryHandler;
+import com.android.dialer.calllog.VisualVoicemailCallLogFragment;
import com.android.dialer.logging.Logger;
import com.android.dialer.logging.ScreenEvent;
import com.android.dialer.util.DialerUtils;
@@ -126,7 +127,7 @@ public class ListsFragment extends Fragment
mAllContactsFragment = new AllContactsFragment();
return mAllContactsFragment;
case TAB_INDEX_VOICEMAIL:
- mVoicemailFragment = new CallLogFragment(Calls.VOICEMAIL_TYPE);
+ mVoicemailFragment = new VisualVoicemailCallLogFragment();
return mVoicemailFragment;
}
throw new IllegalStateException("No fragment at position " + position);