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

Commit b674c9f1 authored by Suchand Ghosh's avatar Suchand Ghosh Committed by Linux Build Service Account
Browse files

Dialer app changes for IMS

IMS Conference URI UI changes
1. Add a new button for initiating conference
URI call in the Dial screen.
2. Send a intent for the conference call with a
extra to indicate the call type as conference.

Change-Id: If78c82bec2d583f9012ea2e824589a6099f76a94
CRs-Fixed: 713839
parent 42a04b56
Loading
Loading
Loading
Loading
+3.11 KiB
Loading image diff...
+15 −6
Original line number Diff line number Diff line
@@ -37,24 +37,33 @@
            android:clipChildren="false" />
    </FrameLayout>

    <FrameLayout
    <LinearLayout
        android:id="@+id/floating_action_button_container"
        android:background="@drawable/fab_blue"
        android:layout_width="@dimen/floating_action_button_width"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/floating_action_button_height"
        android:layout_marginBottom="@dimen/floating_action_button_margin_bottom"
        android:layout_gravity="center_horizontal|bottom">

        <ImageButton
            android:id="@+id/floating_action_button"
            android:background="@drawable/floating_action_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="bottom|left"
            android:layout_weight="1"
            android:background="@drawable/floating_action_button"
            android:contentDescription="@string/action_menu_dialpad_button"
            android:src="@drawable/fab_ic_dial"/>

    </FrameLayout>

       <ImageButton
            android:id="@+id/dialConferenceButton"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="bottom|right"
            android:layout_weight="1"
            android:background="@drawable/floating_action_button"
            android:contentDescription="@string/action_menu_dialpad_button"
            android:src="@drawable/ic_add_group_holo_dark"/>
    </LinearLayout>
    <!-- Host container for the contact tile drag shadow -->
    <FrameLayout
        android:id="@+id/activity_overlay"
+86 −6
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemProperties;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents;
import android.speech.RecognizerIntent;
@@ -88,6 +89,7 @@ import com.android.dialer.widget.SearchEditTextLayout.OnBackButtonClickedListene
import com.android.dialerbind.DatabaseHelperManager;
import com.android.incallui.CallCardFragment;
import com.android.phone.common.animation.AnimUtils;
import com.android.internal.telephony.TelephonyProperties;
import com.android.phone.common.animation.AnimationListenerAdapter;

import java.util.ArrayList;
@@ -99,6 +101,7 @@ import java.util.List;
public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener,
        DialpadFragment.OnDialpadQueryChangedListener,
        OnListFragmentScrolledListener,
        DialpadFragment.HostInterface,
        ListsFragment.HostInterface,
        SpeedDialFragment.HostInterface,
        SearchFragment.HostInterface,
@@ -152,6 +155,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
     */
    private SmartDialSearchFragment mSmartDialSearchFragment;

    private boolean mDialConferenceButtonPressed = false;

    /**
     * Animation that slides in.
     */
@@ -212,13 +217,16 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
    private PopupMenu mOverflowMenu;
    private EditText mSearchView;
    private View mVoiceSearchButton;
    private View mDialCallButton;

    private String mSearchQuery;

    private DialerDatabaseHelper mDialerDatabaseHelper;
    private DragDropController mDragDropController;
    private ActionBarController mActionBarController;
    private ImageButton mFloatingActionButton;

    private ImageButton mConferenceDialButton;
    private FloatingActionButtonController mFloatingActionButtonController;

    private int mActionBarHeight;
@@ -378,10 +386,13 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O

        final View floatingActionButtonContainer = findViewById(
                R.id.floating_action_button_container);
        ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
        floatingActionButton.setOnClickListener(this);
        mFloatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
        mDialCallButton =  findViewById(R.id.floating_action_button);
        mFloatingActionButton.setOnClickListener(this);
        mConferenceDialButton = (ImageButton) findViewById(R.id.dialConferenceButton);
        mConferenceDialButton.setOnClickListener(this);
        mFloatingActionButtonController = new FloatingActionButtonController(this,
                floatingActionButtonContainer, floatingActionButton);
                floatingActionButtonContainer,mFloatingActionButton);

        ImageButton optionsMenuButton =
                (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button);
@@ -474,6 +485,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
        prepareVoiceSearchButton();
        mDialerDatabaseHelper.startSmartDialUpdateThread();
        updateFloatingActionButtonControllerAlignment(false /* animate */);
        setConferenceDialButtonImage(false);
        setConferenceDialButtonVisibility(true);
    }

    @Override
@@ -522,15 +535,41 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
        startActivity(intent);
    }

    public static boolean isCallOnImsEnabled() {
        return (SystemProperties.getBoolean(
                TelephonyProperties.PROPERTY_DBG_IMS_VOLTE_ENABLE, false));
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.floating_action_button:
                mDialConferenceButtonPressed = false;
                if (mDialpadFragment != null) {
                    mDialpadFragment.showDialConference(false);
                }
                if (!mIsDialpadShown) {
                    mInCallDialpadUp = false;
                    showDialpadFragment(true);
                    mFloatingActionButton.setImageResource(R.drawable.fab_ic_call);
                    mFloatingActionButton.setVisibility(view.VISIBLE);
                    setConferenceDialButtonImage(false);
                    setConferenceDialButtonVisibility(true);
                } else {
                    // Dial button was pressed; tell the Dialpad fragment
                    mDialpadFragment.dialButtonPressed();
                }
                break;
            case R.id.dialConferenceButton:
                mDialConferenceButtonPressed = true;
                showDialpadFragment(true);
                mIsDialpadShown = false;
                mDialCallButton.setVisibility(view.VISIBLE);
                mDialpadFragment.dialConferenceButtonPressed();
                mFloatingActionButton.setImageResource(R.drawable.fab_ic_dial);
                updateFloatingActionButtonControllerAlignment(true);
                mFloatingActionButton.setVisibility(view.VISIBLE);
            break;
            case R.id.voice_search_button:
                try {
                    startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),
@@ -626,6 +665,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
            mFloatingActionButtonController.setVisible(false);
        }
        mActionBarController.onDialpadUp();
        setConferenceDialButtonVisibility(animate);

        if (!isInSearchUi()) {
            enterSearchUi(true /* isSmartDial */, mSearchQuery);
@@ -636,6 +676,13 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
     * Callback from child DialpadFragment when the dialpad is shown.
     */
    public void onDialpadShown() {
        if (mDialConferenceButtonPressed) {
            mFloatingActionButton.setImageResource(R.drawable.fab_ic_dial);
            mDialConferenceButtonPressed = false;
        } else {
            mFloatingActionButton.setImageResource(R.drawable.fab_ic_call);
        }
        updateFloatingActionButtonControllerAlignment(mDialpadFragment.getAnimate());
        if (mDialpadFragment.getAnimate()) {
            mDialpadFragment.getView().startAnimation(mSlideIn);
        } else {
@@ -657,13 +704,15 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
        if (clearDialpad) {
            mDialpadFragment.clearDialpad();
        }
        if (!mIsDialpadShown) {
        if (!mIsDialpadShown && !mDialpadFragment.isRecipientsShown()) {
            updateFloatingActionButtonControllerAlignment(animate);
            return;
        }
        mIsDialpadShown = false;
        mDialpadFragment.setAnimate(animate);

        updateSearchFragmentPosition();
        mFloatingActionButton.setImageResource(R.drawable.fab_ic_dial);

        updateFloatingActionButtonControllerAlignment(animate);
        if (animate) {
@@ -684,7 +733,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
    /**
     * Finishes hiding the dialpad fragment after any animations are completed.
     */
    private void commitDialpadFragmentHide() {
    public void commitDialpadFragmentHide() {
        final FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.hide(mDialpadFragment);
        ft.commit();
@@ -924,7 +973,14 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O

    @Override
    public void onBackPressed() {
        if (mIsDialpadShown) {
        setConferenceDialButtonImage(false);
        setConferenceDialButtonVisibility(true);
        boolean mIsRecipientsShown = mDialpadFragment.isRecipientsShown();
        if(mIsRecipientsShown) {
            mDialpadFragment.hideAndClearDialConference();
        }

        if (mIsDialpadShown || mIsRecipientsShown) {
            if (TextUtils.isEmpty(mSearchQuery) ||
                    (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible()
                            && mSmartDialSearchFragment.getAdapter().getCount() == 0)) {
@@ -993,6 +1049,30 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
        // interactions with the ListsFragments.
    }

    @Override
    public void setConferenceDialButtonVisibility(boolean enabled) {
        if(mConferenceDialButton != null) {
            mConferenceDialButton.setVisibility(enabled && isCallOnImsEnabled() ?
                    View.VISIBLE : View.GONE);
        }
    }

    @Override
    public void setConferenceDialButtonImage(boolean setAddParticipantButton) {
        if(mConferenceDialButton != null) {
            /*
             * If dial conference view is shown, button should show dialpad
             * image. Pressing the button again will return to normal dialpad
             * view. If normal dialpad view is shown, button should show dial
             * conference image. Pressing the button again will show dial
             * conference view
             */
            mConferenceDialButton
                    .setImageResource(setAddParticipantButton ? R.drawable.fab_ic_call
                            : R.drawable.ic_add_group_holo_dark);
        }
    }

    private boolean phoneIsInUse() {
        return getTelecomManager().isInCall();
    }
+151 −23
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import com.android.dialer.R;
import com.android.dialer.SpecialCharSequenceMgr;
import com.android.dialer.util.DialerUtils;
import com.android.dialerbind.analytics.AnalyticsFragment;
import com.android.internal.telephony.TelephonyProperties;
import com.android.phone.common.CallLogAsync;
import com.android.phone.common.HapticFeedback;
import com.android.phone.common.animation.AnimUtils;
@@ -99,6 +100,21 @@ public class DialpadFragment extends AnalyticsFragment
        DialpadKeyButton.OnPressedListener {
    private static final String TAG = DialpadFragment.class.getSimpleName();

    /**
     * This interface allows the DialpadFragment to tell its hosting Activity when and when not
     * to display the "dial" button. While this is logically part of the DialpadFragment, the
     * need to have a particular kind of slick animation puts the "dial" button in the parent.
     *
     * The parent calls dialButtonPressed() and optionsMenuInvoked() on the dialpad fragment
     * when appropriate.
     *
     * TODO: Refactor the app so this interchange is a bit cleaner.
     */
    public interface HostInterface {
        void setConferenceDialButtonVisibility(boolean enabled);
        void setConferenceDialButtonImage(boolean setAddParticipantButton);
    }

    /**
     * LinearLayout with getter and setter methods for the translationY property using floats,
     * for animation purposes.
@@ -157,6 +173,9 @@ public class DialpadFragment extends AnalyticsFragment

    private DialpadView mDialpadView;
    private EditText mDigits;
    private EditText mRecipients;
    private View mDigitsContainer;
    private View mDialpad;
    private int mDialpadSlideInDuration;

    /** Remembers if we need to clear digits field when the screen is completely gone. */
@@ -235,6 +254,9 @@ public class DialpadFragment extends AnalyticsFragment
                // onscreen, but useless...)
                showDialpadChooser(false);
            }
            if (state == TelephonyManager.CALL_STATE_IDLE) {
                ((HostInterface) getActivity()).setConferenceDialButtonVisibility(true);
            }
        }
    };

@@ -345,6 +367,13 @@ public class DialpadFragment extends AnalyticsFragment
        mDialpadView = (DialpadView) fragmentView.findViewById(R.id.dialpad_view);
        mDialpadView.setCanDigitsBeEdited(true);
        mDigits = mDialpadView.getDigits();
        mRecipients = (EditText) fragmentView.findViewById(R.id.recipients);
        mDigitsContainer = fragmentView.findViewById(R.id.digits_container);
        mDialpad = fragmentView.findViewById(R.id.dialpad);
        if (mRecipients != null) {
            mRecipients.setVisibility(View.GONE);
            mRecipients.addTextChangedListener(this);
        }
        mDigits.setKeyListener(UnicodeDialerKeyListener.INSTANCE);
        mDigits.setOnClickListener(this);
        mDigits.setOnKeyListener(this);
@@ -639,6 +668,7 @@ public class DialpadFragment extends AnalyticsFragment
            // Also, a sanity-check: the "dialpad chooser" UI should NEVER
            // be visible if the phone is idle!
            showDialpadChooser(false);
            hideAndClearDialpad(true);
        }

        mFirstLaunch = false;
@@ -872,6 +902,79 @@ public class DialpadFragment extends AnalyticsFragment
        return popupMenu;
    }

    /**
     * Called by the containing Activity to tell this Fragment that the dial button has been
     * pressed.
     */
    public void dialButtonPressed() {
        mHaptic.vibrate();
        handleDialButtonPressed();
    }

    public void dialConferenceButtonPressed() {
        // show dial conference screen if it is not shown
        // If it is already shown, show normal dial screen
        boolean show = (mRecipients != null) && !mRecipients.isShown();
        Log.d(TAG, "dialConferenceButtonPressed show " + show);
        if (show) {
            showDialConference(show);
        } else {
            handleDialButtonPressed();
            showDialConference(!show);
        }
    }

    public void showDialConference(boolean enabled) {
        // Check if onCreateView() is already called by checking one of View
        // objects.
        if (!isLayoutReady()) {
            return;
        }
        Log.d(TAG, "showDialConference " + enabled);
        /*
         * if enabled is true then pick child views that should be
         * visible/invisible when dialpad is choosen from conference dial button
         * if enabled is false then pick child views that should be
         * visible/invisible when dialpad is choosen from other buttons
         */

        // viewable when choosen through conference button
        int conferenceButtonVisibility = (enabled ? View.VISIBLE : View.GONE);
        // not viewable when choosen through conference button
        int nonConferenceButtonVisibility = (enabled ? View.GONE : View.VISIBLE);

        // change the image visibility of the button
        if (mRecipients != null)
            mRecipients.setVisibility(conferenceButtonVisibility);
        if (mDigits != null)
            mDigits.setVisibility(nonConferenceButtonVisibility);
        if (mDelete != null)
            mDelete.setVisibility(nonConferenceButtonVisibility);
        if (mDialpad != null)
            mDialpad.setVisibility(enabled ? View.INVISIBLE : View.VISIBLE);

        if (enabled && (HostInterface)getActivity() != null) {
            ((HostInterface)getActivity()).setConferenceDialButtonImage(enabled);
        }
    }

    public void hideAndClearDialConference() {
        // hide the image visibility of the button
        if (mRecipients != null)
            mRecipients.setVisibility(View.GONE);
        if (mDigits != null)
            mDigits.setVisibility(View.GONE);
        if (mDelete != null)
            mDelete.setVisibility(View.GONE);
        if (mDialpad != null)
            mDialpad.setVisibility(View.GONE);
        ((DialtactsActivity) getActivity()).commitDialpadFragmentHide();
    }

    public boolean isRecipientsShown() {
        return mRecipients != null && mRecipients.isShown();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
@@ -1049,11 +1152,24 @@ public class DialpadFragment extends AnalyticsFragment
     * case described above).
     */
    private void handleDialButtonPressed() {
        if (isDigitsEmpty()) { // No number entered.
        if (isDigitsEmpty() && (mRecipients == null || !mRecipients.isShown())) {
            // No number entered.
            handleDialButtonClickWithEmptyDigits();
        } else {
            final String number = mDigits.getText().toString();

            boolean isDigitsShown = mDigits.isShown();
            final String number = isDigitsShown ? mDigits.getText().toString() :
                    mRecipients.getText().toString().trim();
            if (isDigitsShown && isDigitsEmpty()) {
                handleDialButtonClickWithEmptyDigits();
            } else if (isDigitsEmpty() && mRecipients.isShown() && isRecipientEmpty()) {
                // mRecipients must be empty
                // TODO add support for conference URI in last number dialed
                // use ErrorDialogFragment instead? also see
                // android.app.AlertDialog
                android.widget.Toast.makeText(getActivity(),
                        "Error: Cannot dial.  Please provide conference recipients.",
                        android.widget.Toast.LENGTH_SHORT).show();
            } else {
                // "persist.radio.otaspdial" is a temporary hack needed for one carrier's automated
                // test equipment.
                // TODO: clean it up.
@@ -1073,11 +1189,16 @@ public class DialpadFragment extends AnalyticsFragment
                    final Intent intent = CallUtil.getCallIntent(number,
                            (getActivity() instanceof DialtactsActivity ?
                                    ((DialtactsActivity) getActivity()).getCallOrigin() : null));
                    if (!isDigitsShown) {
                        // must be dial conference add extra
                        intent.putExtra(TelephonyProperties.EXTRA_DIAL_CONFERENCE_URI, true);
                    }
                    DialerUtils.startActivityWithErrorToast(getActivity(), intent);
                    hideAndClearDialpad(false);
                }
            }
        }
    }

    public void clearDialpad() {
        mDigits.getText().clear();
@@ -1563,6 +1684,13 @@ public class DialpadFragment extends AnalyticsFragment
        return mDigits.length() == 0;
    }

    /**
     * @return true if the widget with the mRecipients is empty.
     */
    private boolean isRecipientEmpty() {
        return  (mRecipients == null) || (mRecipients.length() == 0);
    }

    /**
     * Starts the asyn query to get the last dialed/outgoing
     * number. When the background query finishes, mLastNumberDialed