From 76cf7e18da00545145df8a5f215f3a377d605866 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Wed, 28 Feb 2018 17:10:18 -0800 Subject: Some small bug fixes in NUI. - Never show the dialpad chooser in MainActivity. - If the call log changed while dialer was in the background, it would trigger the content observer to fetch the new info, which would request it's parent that wasn't there. Now we register/unregister them in onResume/onPause. This is safe to do because we force refresh the data onResume anyways, so any changes will still be shown. Bug: 73972084,73975555,73995512 Test: manual PiperOrigin-RevId: 187407058 Change-Id: Iae86dabbcb852398bb2b9df4627e234261ab8030 --- .../com/android/dialer/main/impl/OldMainActivityPeer.java | 6 ++++++ .../com/android/dialer/main/impl/toolbar/MainToolbar.java | 7 ++++--- .../android/dialer/main/impl/toolbar/SearchBarView.java | 15 ++++++++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'java/com/android/dialer/main') diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 2999c6b0b..ee0dad5b8 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -651,6 +651,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen // No-op, just let the clicks fall through to the search list return false; } + + @Override + public boolean shouldShowDialpadChooser() { + // Never show the dialpad chooser. Ever. + return false; + } } /** @see CallLogAdapter.OnActionModeStateChangedListener */ diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java index fc4bd0312..2f36717c9 100644 --- a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java +++ b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java @@ -19,6 +19,7 @@ package com.android.dialer.main.impl.toolbar; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.content.Context; +import android.support.annotation.NonNull; import android.support.annotation.StringRes; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; @@ -66,9 +67,9 @@ public final class MainToolbar extends Toolbar implements PopupMenu.OnMenuItemCl return listener.onMenuItemClicked(menuItem); } - public void setSearchBarListener(SearchBarListener listener) { - this.listener = listener; - ((SearchBarView) findViewById(R.id.search_view_container)).setSearchBarListener(listener); + public void setSearchBarListener(@NonNull SearchBarListener listener) { + this.listener = Assert.isNotNull(listener); + searchBar.setSearchBarListener(listener); } /** Slides the toolbar up and off the screen. */ diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java index 78cabf733..299985057 100644 --- a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java +++ b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java @@ -32,6 +32,7 @@ import android.widget.EditText; import android.widget.FrameLayout; import android.widget.TextView; import com.android.dialer.animation.AnimUtils; +import com.android.dialer.common.Assert; import com.android.dialer.common.UiUtil; import com.android.dialer.util.DialerUtils; import com.google.common.base.Optional; @@ -188,8 +189,8 @@ final class SearchBarView extends FrameLayout { requestLayout(); } - /* package-private */ void setSearchBarListener(SearchBarListener listener) { - this.listener = listener; + /* package-private */ void setSearchBarListener(@NonNull SearchBarListener listener) { + this.listener = Assert.isNotNull(listener); } public String getQuery() { @@ -236,7 +237,15 @@ final class SearchBarView extends FrameLayout { return; } - listener.onSearchQueryUpdated(s.toString()); + // afterTextChanged is called each time the device is rotated (or the activity is recreated). + // That means that this method could potentially be called before the listener is set and + // we should check if it's null. In the case that it is null, assert that the query is empty + // because the listener must be notified of non-empty queries. + if (listener != null) { + listener.onSearchQueryUpdated(s.toString()); + } else { + Assert.checkArgument(TextUtils.isEmpty(s.toString())); + } } } } -- cgit v1.2.3