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

Commit 1c6f3817 authored by Flavio Lerda's avatar Flavio Lerda
Browse files

Remove CallLogActivity.

CallLogActivity was only used by tests. Instead, extend
FragmentTestActivity to handle loading of an arbitrary fragment into it,
so that we can test the CallLogFragment within it.

So far, FragmentTestActivity was only used with a UI-less fragment,
which therefore did not need a placeholder for the fragment.

Bug: 5286366
Change-Id: I939d6fb212621345b8a1ba4ec1a3b1c56909ce50
parent c1313a5f
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
@@ -56,19 +56,6 @@
        android:hardwareAccelerated="true"
    >

        <!-- A list of recent calls -->
        <activity android:name=".activities.CallLogActivity"
            android:label="@string/recentCallsIconLabel"
            android:theme="@style/DialtactsTheme"
            android:uiOptions="splitActionBarWhenNarrow"
        >
            <intent-filter>
                <action android:name="com.android.phone.action.RECENT_CALLS" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.TAB" />
            </intent-filter>
        </activity>

        <!-- Intercept Dialer Intents for devices without a phone.
        This activity should have the same intent filters as the DialtactsActivity,
        so that its capturing the same events. Omit android.intent.category.LAUNCHER, because we
@@ -182,6 +169,11 @@
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.TAB" />
            </intent-filter>
            <intent-filter android:label="@string/recentCallsIconLabel">
                <action android:name="com.android.phone.action.RECENT_CALLS" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.TAB" />
            </intent-filter>
        </activity>

        <!-- The main Contacts activity with the contact list, favorites, and groups. -->
@@ -330,6 +322,18 @@
            android:exported="true"
        />

        <!-- Backwards compatibility: "Call log" from Gingerbread and earlier -->
        <activity-alias android:name="RecentCallsListActivity"
            android:targetActivity=".activities.DialtactsActivity"
            android:exported="true"
        />

        <!-- Backwards compatibility: "Call log" from ICS -->
        <activity-alias android:name=".activities.CallLogActivity"
            android:targetActivity=".activities.DialtactsActivity"
            android:exported="true"
        />

        <!-- An activity for joining contacts -->
        <activity android:name=".activities.JoinContactActivity"
            android:theme="@style/JoinContactActivityTheme"
+3 −2
Original line number Diff line number Diff line
@@ -18,8 +18,9 @@
    android:layout_width="match_parent"
    android:layout_height="match_parent"
>
    <fragment class="com.android.contacts.calllog.CallLogFragment"
            android:id="@+id/call_log_fragment"
    <!-- Placeholder to load the fragment under test. -->
    <fragment android:id="@+id/fragment"
            android:name="com.android.contacts.test.EmptyFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
</FrameLayout>
+0 −101
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 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.contacts.activities;

import com.android.contacts.R;
import com.android.contacts.calllog.CallLogFragment;
import com.android.internal.telephony.ITelephony;
import com.google.common.annotations.VisibleForTesting;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.view.KeyEvent;
import android.view.ViewConfiguration;

/**
 * Displays a list of call log entries.
 */
public class CallLogActivity extends Activity {
    private static final String TAG = "CallLogActivity";

    private CallLogFragment mFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        setContentView(R.layout.call_log_activity);

        // Typing here goes to the dialer
        setDefaultKeyMode(DEFAULT_KEYS_DIALER);

        mFragment = (CallLogFragment) getFragmentManager().findFragmentById(
                R.id.call_log_fragment);
    }

    @VisibleForTesting
    /*package*/ CallLogFragment getFragment() {
        return mFragment;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_CALL: {
                long callPressDiff = SystemClock.uptimeMillis() - event.getDownTime();
                if (callPressDiff >= ViewConfiguration.getLongPressTimeout()) {
                    // Launch voice dialer
                    Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    try {
                        startActivity(intent);
                    } catch (ActivityNotFoundException e) {
                    }
                    return true;
                }
            }
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_CALL:
                try {
                    ITelephony phone = ITelephony.Stub.asInterface(
                            ServiceManager.checkService("phone"));
                    if (phone != null && !phone.isIdle()) {
                        // Let the super class handle it
                        break;
                    }
                } catch (RemoteException re) {
                    // Fall through and try to call the contact
                }

                mFragment.callSelectedEntry();
                return true;
        }
        return super.onKeyUp(keyCode, event);
    }
}
+13 −21
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ import libcore.util.Objects;
/**
 * Adapter class to fill in data for the Call Log.
 */
public class CallLogAdapter extends GroupingListAdapter
/*package*/ class CallLogAdapter extends GroupingListAdapter
        implements Runnable, ViewTreeObserver.OnPreDrawListener, CallLogGroupBuilder.GroupCreator {
    /** Interface used to initiate a refresh of the content. */
    public interface CallFetcher {
@@ -193,7 +193,7 @@ public class CallLogAdapter extends GroupingListAdapter
        }
    };

    public CallLogAdapter(Context context, CallFetcher callFetcher,
    CallLogAdapter(Context context, CallFetcher callFetcher,
            ContactInfoHelper contactInfoHelper) {
        super(context);

@@ -240,11 +240,7 @@ public class CallLogAdapter extends GroupingListAdapter
        }
    }

    public ContactInfo getContactInfo(String number) {
        return mContactInfoCache.getPossiblyExpired(number);
    }

    public void startRequestProcessing() {
    private void startRequestProcessing() {
        if (mRequestProcessingDisabled) {
            return;
        }
@@ -368,9 +364,8 @@ public class CallLogAdapter extends GroupingListAdapter
        mCallLogGroupBuilder.addGroups(cursor);
    }

    @VisibleForTesting
    @Override
    public View newStandAloneView(Context context, ViewGroup parent) {
    protected View newStandAloneView(Context context, ViewGroup parent) {
        LayoutInflater inflater =
                (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.call_log_list_item, parent, false);
@@ -378,15 +373,13 @@ public class CallLogAdapter extends GroupingListAdapter
        return view;
    }

    @VisibleForTesting
    @Override
    public void bindStandAloneView(View view, Context context, Cursor cursor) {
    protected void bindStandAloneView(View view, Context context, Cursor cursor) {
        bindView(view, cursor, 1);
    }

    @VisibleForTesting
    @Override
    public View newChildView(Context context, ViewGroup parent) {
    protected View newChildView(Context context, ViewGroup parent) {
        LayoutInflater inflater =
                (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.call_log_list_item, parent, false);
@@ -394,15 +387,13 @@ public class CallLogAdapter extends GroupingListAdapter
        return view;
    }

    @VisibleForTesting
    @Override
    public void bindChildView(View view, Context context, Cursor cursor) {
    protected void bindChildView(View view, Context context, Cursor cursor) {
        bindView(view, cursor, 1);
    }

    @VisibleForTesting
    @Override
    public View newGroupView(Context context, ViewGroup parent) {
    protected View newGroupView(Context context, ViewGroup parent) {
        LayoutInflater inflater =
                (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.call_log_list_item, parent, false);
@@ -410,9 +401,8 @@ public class CallLogAdapter extends GroupingListAdapter
        return view;
    }

    @VisibleForTesting
    @Override
    public void bindGroupView(View view, Context context, Cursor cursor, int groupSize,
    protected void bindGroupView(View view, Context context, Cursor cursor, int groupSize,
            boolean expanded) {
        bindView(view, cursor, groupSize);
    }
@@ -678,11 +668,13 @@ public class CallLogAdapter extends GroupingListAdapter
     * This method should be called in tests to disable such processing of requests when not
     * needed.
     */
    public void disableRequestProcessingForTest() {
    @VisibleForTesting
    void disableRequestProcessingForTest() {
        mRequestProcessingDisabled = true;
    }

    public void injectContactInfoForTest(String number, ContactInfo contactInfo) {
    @VisibleForTesting
    void injectContactInfoForTest(String number, ContactInfo contactInfo) {
        mContactInfoCache.put(number, contactInfo);
    }

+4 −3
Original line number Diff line number Diff line
@@ -20,12 +20,12 @@ import com.android.common.io.MoreCloseables;
import com.android.contacts.ContactsUtils;
import com.android.contacts.R;
import com.android.contacts.activities.DialtactsActivity.ViewPagerVisibilityListener;
import com.android.contacts.test.NeededForTesting;
import com.android.contacts.voicemail.VoicemailStatusHelper;
import com.android.contacts.voicemail.VoicemailStatusHelper.StatusMessage;
import com.android.contacts.voicemail.VoicemailStatusHelperImpl;
import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.ITelephony;
import com.google.common.annotations.VisibleForTesting;

import android.app.Activity;
import android.app.KeyguardManager;
@@ -275,6 +275,7 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
                return false;
        }
    }

    public void callSelectedEntry() {
        int position = getListView().getSelectedItemPosition();
        if (position < 0) {
@@ -317,8 +318,8 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
        }
    }

    @NeededForTesting
    public CallLogAdapter getAdapter() {
    @VisibleForTesting
    CallLogAdapter getAdapter() {
        return mAdapter;
    }

Loading