Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76cf7e18 authored by calderwoodra's avatar calderwoodra Committed by Copybara-Service
Browse files

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
parent 999b5d5a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1453,6 +1453,12 @@ public class DialtactsActivity extends TransactionSafeActivity
    return false;
  }

  @Override
  public boolean shouldShowDialpadChooser() {
    // Show the dialpad chooser if we're in a call
    return true;
  }

  @Override
  public void onSearchListTouch() {
    if (isDialpadShown) {
+15 −15
Original line number Diff line number Diff line
@@ -222,18 +222,6 @@ public class CallLogFragment extends Fragment
    final Activity activity = getActivity();
    final ContentResolver resolver = activity.getContentResolver();
    callLogQueryHandler = new CallLogQueryHandler(activity, resolver, this, logLimit);

    if (PermissionsUtil.hasCallLogReadPermissions(getContext())) {
      resolver.registerContentObserver(CallLog.CONTENT_URI, true, callLogObserver);
    } else {
      LogUtil.w("CallLogFragment.onCreate", "call log permission not available");
    }
    if (PermissionsUtil.hasContactsReadPermissions(getContext())) {
      resolver.registerContentObserver(
          ContactsContract.Contacts.CONTENT_URI, true, contactsObserver);
    } else {
      LogUtil.w("CallLogFragment.onCreate", "contacts permission not available.");
    }
    setHasOptionsMenu(true);
  }

@@ -412,6 +400,19 @@ public class CallLogFragment extends Fragment
      updateEmptyMessage(callTypeFilter);
    }

    ContentResolver resolver = getActivity().getContentResolver();
    if (PermissionsUtil.hasCallLogReadPermissions(getContext())) {
      resolver.registerContentObserver(CallLog.CONTENT_URI, true, callLogObserver);
    } else {
      LogUtil.w("CallLogFragment.onCreate", "call log permission not available");
    }
    if (PermissionsUtil.hasContactsReadPermissions(getContext())) {
      resolver.registerContentObserver(
          ContactsContract.Contacts.CONTENT_URI, true, contactsObserver);
    } else {
      LogUtil.w("CallLogFragment.onCreate", "contacts permission not available.");
    }

    this.hasReadCallLogPermission = hasReadCallLogPermission;

    /*
@@ -432,6 +433,8 @@ public class CallLogFragment extends Fragment
  @Override
  public void onPause() {
    LogUtil.enterBlock("CallLogFragment.onPause");
    getActivity().getContentResolver().unregisterContentObserver(callLogObserver);
    getActivity().getContentResolver().unregisterContentObserver(contactsObserver);
    if (getUserVisibleHint()) {
      onNotVisible();
    }
@@ -465,9 +468,6 @@ public class CallLogFragment extends Fragment
    if (adapter != null) {
      adapter.changeCursor(null);
    }

    getActivity().getContentResolver().unregisterContentObserver(callLogObserver);
    getActivity().getContentResolver().unregisterContentObserver(contactsObserver);
    super.onDestroy();
  }

+6 −1
Original line number Diff line number Diff line
@@ -1312,7 +1312,9 @@ public class DialpadFragment extends Fragment
   *     or ringing or dialing, or on hold).
   */
  private boolean isPhoneInUse() {
    return getContext() != null && TelecomUtil.isInManagedCall(getContext());
    return getContext() != null
        && TelecomUtil.isInManagedCall(getContext())
        && FragmentUtils.getParentUnsafe(this, HostInterface.class).shouldShowDialpadChooser();
  }

  /** @return true if the phone is a CDMA phone type */
@@ -1584,6 +1586,9 @@ public class DialpadFragment extends Fragment
     * unless there happens to be content showing.
     */
    boolean onDialpadSpacerTouchWithEmptyQuery();

    /** Returns true if this fragment's parent want the dialpad to show the dialpad chooser. */
    boolean shouldShowDialpadChooser();
  }

  /**
+6 −0
Original line number Diff line number Diff line
@@ -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 */
+4 −3
Original line number Diff line number Diff line
@@ -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. */
Loading