summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/app/calllog/CallLogActivity.java50
-rw-r--r--java/com/android/dialer/app/calllog/CallLogFragment.java10
-rw-r--r--java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java4
3 files changed, 57 insertions, 7 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogActivity.java b/java/com/android/dialer/app/calllog/CallLogActivity.java
index c83d992ee..4b65ed934 100644
--- a/java/com/android/dialer/app/calllog/CallLogActivity.java
+++ b/java/com/android/dialer/app/calllog/CallLogActivity.java
@@ -21,6 +21,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
+import android.support.annotation.VisibleForTesting;
import android.support.design.widget.Snackbar;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
@@ -33,6 +34,7 @@ import com.android.contacts.common.list.ViewPagerTabs;
import com.android.dialer.app.DialtactsActivity;
import com.android.dialer.app.R;
import com.android.dialer.calldetails.CallDetailsActivity;
+import com.android.dialer.common.Assert;
import com.android.dialer.constants.ActivityRequestCodes;
import com.android.dialer.database.CallLogQueryHandler;
import com.android.dialer.logging.Logger;
@@ -47,15 +49,17 @@ import com.android.dialer.util.ViewUtil;
public class CallLogActivity extends TransactionSafeActivity
implements ViewPager.OnPageChangeListener {
- private static final int TAB_INDEX_ALL = 0;
- private static final int TAB_INDEX_MISSED = 1;
+ @VisibleForTesting static final int TAB_INDEX_ALL = 0;
+ @VisibleForTesting static final int TAB_INDEX_MISSED = 1;
private static final int TAB_INDEX_COUNT = 2;
private ViewPager mViewPager;
private ViewPagerTabs mViewPagerTabs;
private ViewPagerAdapter mViewPagerAdapter;
private CallLogFragment mAllCallsFragment;
+ private CallLogFragment mMissedCallsFragment;
private String[] mTabTitles;
private boolean mIsResumed;
+ private int selectedPageIndex;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -78,6 +82,7 @@ public class CallLogActivity extends TransactionSafeActivity
startingTab = TAB_INDEX_MISSED;
}
}
+ selectedPageIndex = startingTab;
mTabTitles = new String[TAB_INDEX_COUNT];
mTabTitles[0] = getString(R.string.call_log_all_title);
@@ -117,6 +122,16 @@ public class CallLogActivity extends TransactionSafeActivity
}
@Override
+ protected void onStop() {
+ if (!isChangingConfigurations() && mViewPager != null) {
+ // Make sure current index != selectedPageIndex
+ selectedPageIndex = -1;
+ updateMissedCalls(mViewPager.getCurrentItem());
+ }
+ super.onStop();
+ }
+
+ @Override
public boolean onCreateOptionsMenu(Menu menu) {
final MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.call_log_options, menu);
@@ -160,6 +175,8 @@ public class CallLogActivity extends TransactionSafeActivity
@Override
public void onPageSelected(int position) {
+ updateMissedCalls(position);
+ selectedPageIndex = position;
if (mIsResumed) {
sendScreenViewForChildFragment();
}
@@ -182,6 +199,26 @@ public class CallLogActivity extends TransactionSafeActivity
return position;
}
+ private void updateMissedCalls(int position) {
+ if (position == selectedPageIndex) {
+ return;
+ }
+ switch (getRtlPosition(position)) {
+ case TAB_INDEX_ALL:
+ if (mAllCallsFragment != null) {
+ mAllCallsFragment.markMissedCallsAsReadAndRemoveNotifications();
+ }
+ break;
+ case TAB_INDEX_MISSED:
+ if (mMissedCallsFragment != null) {
+ mMissedCallsFragment.markMissedCallsAsReadAndRemoveNotifications();
+ }
+ break;
+ default:
+ throw Assert.createIllegalStateFailException("Invalid position: " + position);
+ }
+ }
+
@Override
public void onBackPressed() {
PerformanceReport.recordClick(UiAction.Type.PRESS_ANDROID_BACK_BUTTON);
@@ -216,8 +253,15 @@ public class CallLogActivity extends TransactionSafeActivity
@Override
public Object instantiateItem(ViewGroup container, int position) {
final CallLogFragment fragment = (CallLogFragment) super.instantiateItem(container, position);
- if (getRtlPosition(position) == TAB_INDEX_ALL) {
+ switch (getRtlPosition(position)) {
+ case TAB_INDEX_ALL:
mAllCallsFragment = fragment;
+ break;
+ case TAB_INDEX_MISSED:
+ mMissedCallsFragment = fragment;
+ break;
+ default:
+ throw Assert.createIllegalStateFailException("Invalid position: " + position);
}
return fragment;
}
diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java
index 5e8da032b..6910f1918 100644
--- a/java/com/android/dialer/app/calllog/CallLogFragment.java
+++ b/java/com/android/dialer/app/calllog/CallLogFragment.java
@@ -20,6 +20,7 @@ import static android.Manifest.permission.READ_CALL_LOG;
import android.app.Activity;
import android.app.Fragment;
+import android.app.KeyguardManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -602,6 +603,15 @@ public class CallLogFragment extends Fragment
mDisplayUpdateHandler.removeMessages(EVENT_UPDATE_DISPLAY);
}
+ /** Mark all missed calls as read if Keyguard not locked and possible. */
+ void markMissedCallsAsReadAndRemoveNotifications() {
+ if (mCallLogQueryHandler != null
+ && !getContext().getSystemService(KeyguardManager.class).isKeyguardLocked()) {
+ mCallLogQueryHandler.markMissedCallsAsRead();
+ CallLogNotificationsService.cancelAllMissedCalls(getContext());
+ }
+ }
+
@CallSuper
public void onVisible() {
LogUtil.enterBlock("CallLogFragment.onPageSelected");
diff --git a/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java b/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java
index b7c8ed721..2787320fa 100644
--- a/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java
+++ b/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java
@@ -403,10 +403,6 @@ public class VoicemailTosMessageCreator {
}
private CharSequence getVvmDialerTos() {
- if (!isVoicemailTranscriptionEnabled()) {
- return "";
- }
-
return context.getString(R.string.dialer_terms_and_conditions_for_verizon_1_0);
}