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

Commit 68e3bd08 authored by Danny Baumann's avatar Danny Baumann Committed by Michael Bestas
Browse files

Re-add call statistics.

Change-Id: I9f2b6e912ca69a5aa7a1790bed06304ee953e752
parent d3f1c959
Loading
Loading
Loading
Loading
+27 −6
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import android.view.ViewGroup;
import com.android.contacts.common.list.ViewPagerTabs;
import com.android.dialer.app.R;
import com.android.dialer.calldetails.OldCallDetailsActivity;
import com.android.dialer.callstats.CallStatsFragment;
import com.android.dialer.callstats.DoubleDatePickerDialog;
import com.android.dialer.common.Assert;
import com.android.dialer.constants.ActivityRequestCodes;
import com.android.dialer.database.CallLogQueryHandler;
@@ -45,17 +47,19 @@ import com.android.dialer.util.TransactionSafeActivity;
import com.android.dialer.util.ViewUtil;

/** Activity for viewing call history. */
public class CallLogActivity extends TransactionSafeActivity
    implements ViewPager.OnPageChangeListener {
public class CallLogActivity extends TransactionSafeActivity implements
    ViewPager.OnPageChangeListener, DoubleDatePickerDialog.OnDateSetListener {

  @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 static final int TAB_INDEX_STATS = 2;
  private static final int TAB_INDEX_COUNT = 3;
  private ViewPager viewPager;
  private ViewPagerTabs viewPagerTabs;
  private ViewPagerAdapter viewPagerAdapter;
  private CallLogFragment allCallsFragment;
  private CallLogFragment missedCallsFragment;
  private CallStatsFragment statsFragment;
  private String[] tabTitles;
  private boolean isResumed;
  private int selectedPageIndex;
@@ -86,6 +90,7 @@ public class CallLogActivity extends TransactionSafeActivity
    tabTitles = new String[TAB_INDEX_COUNT];
    tabTitles[0] = getString(R.string.call_log_all_title);
    tabTitles[1] = getString(R.string.call_log_missed_title);
    tabTitles[2] = getString(R.string.call_log_stats_title);

    viewPager = (ViewPager) findViewById(R.id.call_log_pager);

@@ -187,6 +192,15 @@ public class CallLogActivity extends TransactionSafeActivity
    viewPagerTabs.onPageScrollStateChanged(state);
  }

  @Override
  public void onDateSet(long from, long to) {
    switch (viewPager.getCurrentItem()) {
      case TAB_INDEX_STATS:
        statsFragment.onDateSet(from, to);
        break;
    }
  }

  private void sendScreenViewForChildFragment() {
    Logger.get(this).logScreenView(ScreenEvent.Type.CALL_LOG_FILTER, this);
  }
@@ -213,6 +227,8 @@ public class CallLogActivity extends TransactionSafeActivity
          missedCallsFragment.markMissedCallsAsReadAndRemoveNotifications();
        }
        break;
      case TAB_INDEX_STATS:
        break;
      default:
        throw Assert.createIllegalStateFailException("Invalid position: " + position);
    }
@@ -244,6 +260,8 @@ public class CallLogActivity extends TransactionSafeActivity
              CallLogQueryHandler.CALL_TYPE_ALL, true /* isCallLogActivity */);
        case TAB_INDEX_MISSED:
          return new CallLogFragment(Calls.MISSED_TYPE, true /* isCallLogActivity */);
        case TAB_INDEX_STATS:
          return new CallStatsFragment();
        default:
          throw new IllegalStateException("No fragment at position " + position);
      }
@@ -251,13 +269,16 @@ public class CallLogActivity extends TransactionSafeActivity

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
      final CallLogFragment fragment = (CallLogFragment) super.instantiateItem(container, position);
      final Object fragment = super.instantiateItem(container, position);
      switch (getRtlPosition(position)) {
        case TAB_INDEX_ALL:
          allCallsFragment = fragment;
          allCallsFragment = (CallLogFragment) fragment;
          break;
        case TAB_INDEX_MISSED:
          missedCallsFragment = fragment;
          missedCallsFragment = (CallLogFragment) fragment;
          break;
        case TAB_INDEX_STATS:
          statsFragment = (CallStatsFragment) fragment;
          break;
        default:
          throw Assert.createIllegalStateFailException("Invalid position: " + position);
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ public class ExpirableCacheHeadlessFragment extends Fragment {
  private static final String FRAGMENT_TAG = "ExpirableCacheHeadlessFragment";
  private static final int CONTACT_INFO_CACHE_SIZE = 100;

  private ExpirableCache<NumberWithCountryIso, ContactInfo> retainedCache;
  private ExpirableCache<NumberWithCountryIso, ContactInfo> retainedCache =
      ExpirableCache.create(CONTACT_INFO_CACHE_SIZE);

  @NonNull
  public static ExpirableCacheHeadlessFragment attach(@NonNull AppCompatActivity parentActivity) {
@@ -57,7 +58,6 @@ public class ExpirableCacheHeadlessFragment extends Fragment {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    retainedCache = ExpirableCache.create(CONTACT_INFO_CACHE_SIZE);
    setRetainInstance(true);
  }

+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2013-2014 The CyanogenMod Project
     Copyright (C) 2018 The LineageOS 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.
-->
<resources>
    <declare-styleable name="LinearColorBar">
        <attr name="redColor" format="color" />
        <attr name="greenColor" format="color" />
        <attr name="blueColor" format="color" />
        <attr name="orangeColor" format="color" />
        <attr name="backgroundColor" format="color" />
    </declare-styleable>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -41,4 +41,6 @@

    <string name="call_via">Call via</string>
    <string name="call_via_dialog_title">Call via\u2026</string>

    <string name="call_log_stats_title">Statistics</string>
</resources>
+4 −2
Original line number Diff line number Diff line
@@ -290,13 +290,15 @@ public class CallTypeIconsView extends View {
      int iconId = R.drawable.quantum_ic_call_received_white_24;
      Drawable drawable = largeIcons ? r.getDrawable(iconId) : getScaledBitmap(context, iconId);
      incoming = drawable.mutate();
      incoming.setColorFilter(r.getColor(R.color.dialer_call_green), PorterDuff.Mode.MULTIPLY);
      incoming.setColorFilter(r.getColor(R.color.answered_incoming_call),
          PorterDuff.Mode.MULTIPLY);

      // Create a rotated instance of the call arrow for outgoing calls.
      iconId = R.drawable.quantum_ic_call_made_white_24;
      drawable = largeIcons ? r.getDrawable(iconId) : getScaledBitmap(context, iconId);
      outgoing = drawable.mutate();
      outgoing.setColorFilter(r.getColor(R.color.dialer_call_green), PorterDuff.Mode.MULTIPLY);
      outgoing.setColorFilter(r.getColor(R.color.answered_outgoing_call),
          PorterDuff.Mode.MULTIPLY);

      // Need to make a copy of the arrow drawable, otherwise the same instance colored
      // above will be recolored here.
Loading