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

Commit 3011bc13 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Make the call log shortcut swipeable

Bug: 10365541
Change-Id: I0301644d3fbb9a0284bbe9b2c468a46474e8c6f8
parent 362c4441
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
<view
    xmlns:android="http://schemas.android.com/apk/res/android"
    class="com.android.dialer.calllog.CallLogListItemView"
    android:id="@+id/call_log_list_item"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
+2 −26
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
@@ -429,22 +427,6 @@ public class CallLogFragment extends ListFragment
        }
    }

    /** Removes the missed call notifications. */
    private void removeMissedCallNotifications() {
        try {
            ITelephony telephony =
                    ITelephony.Stub.asInterface(ServiceManager.getService("phone"));
            if (telephony != null) {
                telephony.cancelMissedCallsNotification();
            } else {
                Log.w(TAG, "Telephony service is null, can't call " +
                        "cancelMissedCallsNotification");
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to clear missed calls notification due to remote exception");
        }
    }

    /** Updates call data and notification state while leaving the call log tab. */
    private void updateOnExit() {
        updateOnTransition(false);
@@ -469,14 +451,8 @@ public class CallLogFragment extends ListFragment
            if (!onEntry) {
                mCallLogQueryHandler.markMissedCallsAsRead();
            }
            removeMissedCallNotifications();
            updateVoicemailNotifications();
        }
            CallLogNotificationsHelper.removeMissedCallNotifications();
            CallLogNotificationsHelper.updateVoicemailNotifications(getActivity());
        }

    private void updateVoicemailNotifications() {
        Intent serviceIntent = new Intent(getActivity(), CallLogNotificationsService.class);
        serviceIntent.setAction(CallLogNotificationsService.ACTION_UPDATE_NOTIFICATIONS);
        getActivity().startService(serviceIntent);
    }
}
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 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.
 */

package com.android.dialer.calllog;

import android.content.Context;
import android.content.Intent;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;

import com.android.internal.telephony.ITelephony;

/**
 * Helper class operating on call log notifications.
 */
public class CallLogNotificationsHelper {
    private static final String TAG = "CallLogNotificationsHelper";

    /** Removes the missed call notifications. */
    public static void removeMissedCallNotifications() {
        try {
            ITelephony telephony =
                    ITelephony.Stub.asInterface(ServiceManager.getService("phone"));
            if (telephony != null) {
                telephony.cancelMissedCallsNotification();
            } else {
                Log.w(TAG, "Telephony service is null, can't call " +
                        "cancelMissedCallsNotification");
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to clear missed calls notification due to remote exception");
        }
    }

    /** Update the voice mail notifications. */
    public static void updateVoicemailNotifications(Context context) {
        Intent serviceIntent = new Intent(context, CallLogNotificationsService.class);
        serviceIntent.setAction(CallLogNotificationsService.ACTION_UPDATE_NOTIFICATIONS);
        context.startService(serviceIntent);
    }
}
+27 −6
Original line number Diff line number Diff line
@@ -132,16 +132,28 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
        mLogLimit = limit;
    }


    /**
     * Fetches the list of calls from the call log for a given type.
     * This call ignores the new or old state.
     * <p>
     * It will asynchronously update the content of the list view when the fetch completes.
     */
    public void fetchCalls(int callType) {
        cancelFetch();
        int requestId = newCallsRequest();
        fetchCalls(QUERY_CALLLOG_TOKEN, requestId, callType);
        fetchCalls(QUERY_CALLLOG_TOKEN, requestId, callType , false /* newOnly */);
    }

    /**
     * Fetches the list of calls from the call log for a given type.
     * This call fetches only the new (i.e. NEW = 1) ones.
     * <p>
     * It will asynchronously update the content of the list view when the fetch completes.
     */
    public void fetchNewCalls(int callType) {
        cancelFetch();
        int requestId = newCallsRequest();
        fetchCalls(QUERY_CALLLOG_TOKEN, requestId, callType , true /* newOnly */);
    }

    public void fetchVoicemailStatus() {
@@ -149,20 +161,29 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
                VoicemailStatusHelperImpl.PROJECTION, null, null, null);
    }

    /** Fetches the list of calls in the call log, either the new one or the old ones. */
    private void fetchCalls(int token, int requestId, int callType) {
    /** Fetches the list of calls in the call log. */
    private void fetchCalls(int token, int requestId, int callType, boolean newOnly) {
        // 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".
        String selection = null;
        StringBuilder where = new StringBuilder();
        List<String> selectionArgs = Lists.newArrayList();

        if (newOnly) {
            where.append(Calls.NEW);
            where.append(" = 1");
        }

        if (callType > CALL_TYPE_ALL) {
            if (where.length() > 0) {
                where.append(" AND ");
            }
            // Add a clause to fetch only items of type voicemail.
            selection = String.format("(%s = ?)", Calls.TYPE);
            where.append(String.format("(%s = ?)", Calls.TYPE));
            selectionArgs.add(Integer.toString(callType));
        }
        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()
                .appendQueryParameter(Calls.LIMIT_PARAM_KEY, Integer.toString(limit))
                .build();
+1 −1
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
    @Override
    public void onResume() {
        super.onResume();
        mCallLogQueryHandler.fetchCalls(CallLogQueryHandler.CALL_TYPE_ALL);
        mCallLogQueryHandler.fetchNewCalls(CallLogQueryHandler.CALL_TYPE_ALL);
        mCallLogAdapter.setLoading(true);
        getLoaderManager().getLoader(LOADER_ID_CONTACT_TILE).forceLoad();
    }
Loading