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

Commit dc609f5a authored by emancebo's avatar emancebo Committed by Gerrit - the friendly Code Review server
Browse files

Port "filter by date range" from call stats page to call log

Change-Id: I78b73c8e59a53143b98f8889dc0085af02364d4c
parent 9835e831
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -46,6 +46,16 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    <include layout="@layout/call_spinner" />

    <TextView
            android:id="@+id/date_filter"
            style="@style/ContactListSeparatorTextViewStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/call_log_outer_margin"
            android:layout_marginEnd="@dimen/call_log_outer_margin"
            android:background="@null"
            android:visibility="gone" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2015 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.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/date_filter"
        android:showAsAction="never"
        android:title="@string/call_stats_date_filter"/>

    <item
        android:id="@+id/reset_date_filter"
        android:showAsAction="never"
        android:visible="false"
        android:title="@string/call_stats_reset_filter"/>
</menu>
+9 −1
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ public class CallLogActivity extends AnalyticsActivity implements
            switch (position) {
                case TAB_INDEX_MSIM:
                    mMSimCallsFragment = new MSimCallLogFragment();
                    mMSimCallsFragment.setHasOptionsMenu(true);
                    return mMSimCallsFragment;
                case TAB_INDEX_MSIM_STATS:
                    mStatsFragment = new CallStatsFragment();
@@ -396,6 +397,13 @@ public class CallLogActivity extends AnalyticsActivity implements

    @Override
    public void onDateSet(long from, long to) {
        switch (mViewPager.getCurrentItem()) {
            case TAB_INDEX_MSIM:
                mMSimCallsFragment.onDateSet(from, to);
                break;
            case TAB_INDEX_MSIM_STATS:
                mStatsFragment.onDateSet(from, to);
                break;
        }
    }
}
+9 −6
Original line number Diff line number Diff line
@@ -33,16 +33,14 @@ import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
import android.provider.VoicemailContract.Status;
import android.util.MutableInt;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver;
import android.widget.ListView;
import android.widget.TextView;

import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.util.ViewUtil;
import com.android.dialer.R;
@@ -205,7 +203,6 @@ public class CallLogFragment extends AnalyticsListFragment
                ContactsContract.Contacts.CONTENT_URI, true, mContactsObserver);
        getActivity().getContentResolver().registerContentObserver(
                Status.CONTENT_URI, true, mVoicemailStatusObserver);
        setHasOptionsMenu(true);
        updateCallList(mCallTypeFilter, mDateLimit);

        mExpandedItemTranslationZ =
@@ -416,7 +413,13 @@ public class CallLogFragment extends AnalyticsListFragment

    @Override
    public void fetchCalls() {
        mCallLogQueryHandler.fetchCalls(mCallTypeFilter, mDateLimit);
        fetchCalls(-1, -1, CallLogQueryHandler.CALL_SUB_ALL);
    }

    protected void fetchCalls(long filterFromDate, long filterToDate, int subId) {
        mCallLogQueryHandler.fetchCallsInDateRange(
                mCallTypeFilter, filterFromDate, filterToDate > 0 ? filterToDate : mDateLimit,
                subId);
    }

    public void startCallsQuery() {
+18 −5
Original line number Diff line number Diff line
@@ -126,12 +126,12 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
     */
    public void fetchCalls(int callType, long newerThan) {
        cancelFetch();
        fetchCalls(QUERY_CALLLOG_TOKEN, callType, false /* newOnly */, newerThan);
        fetchCalls(QUERY_CALLLOG_TOKEN, callType, false /* newOnly */, 0, newerThan);
    }

    public void fetchCalls(int callType, long newerThan, int sub) {
        cancelFetch();
        fetchCalls(QUERY_CALLLOG_TOKEN, callType, false /* newOnly */, newerThan, sub);
        fetchCalls(QUERY_CALLLOG_TOKEN, callType, false /* newOnly */, 0, newerThan, sub);
    }

    public void fetchCalls(int callType) {
@@ -152,18 +152,23 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
                Calls.DEFAULT_SORT_ORDER);
    }

    public void fetchCallsInDateRange(int callType, long fromDate, long toDate, int subId) {
        fetchCalls(QUERY_CALLLOG_TOKEN, callType, false, toDate, fromDate, subId);
    }

    public void fetchVoicemailStatus() {
        startQuery(QUERY_VOICEMAIL_STATUS_TOKEN, null, Status.CONTENT_URI,
                VoicemailStatusHelperImpl.PROJECTION, null, null, null);
    }

    /** Fetches the list of calls in the call log. */
    private void fetchCalls(int token, int callType, boolean newOnly, long newerThan) {
        fetchCalls(token, callType, newOnly, newerThan, CALL_SUB_ALL);
    private void fetchCalls(int token, int callType, boolean newOnly,
                            long olderThan, long newerThan) {
        fetchCalls(token, callType, newOnly, olderThan, newerThan, CALL_SUB_ALL);
    }

    private void fetchCalls(int token, int callType, boolean newOnly,
            long newerThan, int slotId) {
            long olderThan, long newerThan, int slotId) {
        // We need to check for NULL explicitly otherwise entries with where READ is NULL
        // may not match either the query or its negation.
        // We consider the calls that are not yet consumed (i.e. IS_READ = 0) as "new".
@@ -218,6 +223,14 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
            selectionArgs.add(Long.toString(newerThan));
        }

        if (olderThan > 0) {
            if (where.length() > 0) {
                where.append(" AND ");
            }
            where.append(String.format("(%s <= ?)", Calls.DATE));
            selectionArgs.add(Long.toString(olderThan));
        }

        final int limit = (mLogLimit == -1) ? NUM_LOGS_TO_DISPLAY : mLogLimit;
        final String selection = where.length() > 0 ? where.toString() : null;
        Uri uri = Calls.CONTENT_URI_WITH_VOICEMAIL.buildUpon()
Loading