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

Commit c7511865 authored by Daisuke Miyakawa's avatar Daisuke Miyakawa
Browse files

Fix possible NPE. mDigits may be null on onNewIntent()

TESTED:
- launch dialpad screen with a phone Intent
- launch the app during phone calls to show dialpad chooser
- play with dialpad chooser
- launch dialpad screen with a phone Intent during
  phone call

Bug: 5283231
Change-Id: I3fc709eebf40a2ab3b16798729e4f9c07c4b3421
parent 1daa7280
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -294,6 +294,10 @@ public class DialpadFragment extends Fragment
        return fragmentView;
    }

    private boolean isLayoutReady() {
        return mDigits != null;
    }

    public EditText getDigitsWidget() {
        return mDigits;
    }
@@ -393,6 +397,16 @@ public class DialpadFragment extends Fragment
     * the screen to enter "Add Call" mode, this method will show correct UI for the mode.
     */
    public void configureScreenFromIntent(Intent intent) {
        if (!isLayoutReady()) {
            // This happens typically when parent's Activity#onNewIntent() is called while
            // Fragment#onCreateView() isn't called yet, and thus we cannot configure Views at
            // this point. onViewCreate() should call this method after preparing layouts, so
            // just ignore this call now.
            Log.i(TAG,
                    "Screen configuration is requested before onCreateView() is called. Ignored");
            return;
        }

        boolean needToShowDialpadChooser = false;

        final boolean isAddCallMode = isAddCallMode(intent);
@@ -535,7 +549,7 @@ public class DialpadFragment extends Fragment
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        if (mShowOptionsMenu && ViewConfiguration.get(getActivity()).hasPermanentMenuKey() &&
                mDialpadChooser != null && mDigits != null) {
                isLayoutReady() && mDialpadChooser != null) {
            inflater.inflate(R.menu.dialpad_options, menu);
        }
    }
@@ -544,7 +558,7 @@ public class DialpadFragment extends Fragment
    public void onPrepareOptionsMenu(Menu menu) {
        // Hardware menu key should be available and Views should already be ready.
        if (mShowOptionsMenu && ViewConfiguration.get(getActivity()).hasPermanentMenuKey() &&
                mDialpadChooser != null && mDigits != null) {
                isLayoutReady() && mDialpadChooser != null) {
             setupMenuItems(menu);
        }
    }
@@ -896,7 +910,7 @@ public class DialpadFragment extends Fragment
     */
    private void showDialpadChooser(boolean enabled) {
        // Check if onCreateView() is already called by checking one of View objects.
        if (mDigits == null) {
        if (!isLayoutReady()) {
            return;
        }