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

Commit 9838851d authored by Marcus Hagerott's avatar Marcus Hagerott
Browse files

Fix initial focus issues in dialogs and editor

Test: manually launched app on Walleye running P and verified that
keyboard is opened when the create and rename label dialogs are opened.
Also verified that the keyboard remains visible in the editor when
the screen is rotated with an input field focused.

Bug: 77244371
Bug: 77246197
Change-Id: I66638bfae9e17986773395624e3cccc75c95eb10
parent 14f1b446
Loading
Loading
Loading
Loading
+21 −13
Original line number Diff line number Diff line
@@ -15,12 +15,17 @@
     limitations under the License.
-->

<com.android.contacts.editor.RawContactEditorView
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/contact_editor_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_primary" >

    <com.android.contacts.editor.RawContactEditorView
        android:id="@+id/raw_contacts_editor_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/background_primary"
        android:orientation="horizontal"
        android:visibility="invisible">

@@ -34,12 +39,14 @@
            android:focusableInTouchMode="true"/>

        <ScrollView
            android:id="@+id/contact_editor_scroller"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fadingEdge="none"
            android:fillViewport="true">

            <LinearLayout
                android:id="@+id/editor_fields_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
@@ -53,3 +60,4 @@
        </ScrollView>

    </com.android.contacts.editor.RawContactEditorView>
</FrameLayout>
+8 −1
Original line number Diff line number Diff line
@@ -33,4 +33,11 @@
        app:navigationIcon="@drawable/quantum_ic_close_vd_theme_24"
        app:title="@string/contact_editor_title_existing_contact" />

    <fragment
        android:id="@+id/contact_editor_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.android.contacts.editor.ContactEditorFragment"
        android:tag="editor_fragment"/>

</LinearLayout>
+22 −15
Original line number Diff line number Diff line
@@ -15,11 +15,17 @@
     limitations under the License.
-->

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/contact_editor_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
        android:background="@color/background_primary"
    android:background="@color/background_primary" >

    <ScrollView 
        android:id="@+id/contact_editor_scroller"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fadingEdge="none"
        android:fillViewport="true">

@@ -46,3 +52,4 @@
        </com.android.contacts.editor.RawContactEditorView>

    </ScrollView>
</FrameLayout>
+4 −1
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@
    app:errorEnabled="true"
    app:hintEnabled="false">

    <!-- In Android P there is no initial focus by default in touch mode. See b/77244371 -->
    <requestFocus />

    <android.support.design.widget.TextInputEditText
        android:id="@android:id/text1"
        android:layout_width="match_parent"
+4 −22
Original line number Diff line number Diff line
@@ -355,23 +355,15 @@ public class ContactEditorActivity extends AppCompatContactsActivity implements
        // Set activity title for Talkback
        setTitle(mActionBarTitleResId);

        if (savedState == null) {
            // Create the editor and photo selection fragments
            mFragment = new ContactEditorFragment();
            getFragmentManager().beginTransaction()
                    .add(R.id.fragment_container, getEditorFragment(), TAG_EDITOR_FRAGMENT)
                    .commit();
        } else {
        mFragment =
            (ContactEditor) getFragmentManager().findFragmentById(R.id.contact_editor_fragment);

        if (savedState != null) {
            // Restore state
            mPhotoMode = savedState.getInt(STATE_PHOTO_MODE);
            mActionBarTitleResId = savedState.getInt(STATE_ACTION_BAR_TITLE);
            mPhotoUri = Uri.parse(savedState.getString(STATE_PHOTO_URI));

            // Show/hide the editor and photo selection fragments (w/o animations)
            mFragment = (ContactEditorFragment) getFragmentManager()
                    .findFragmentByTag(TAG_EDITOR_FRAGMENT);
            final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
            fragmentTransaction.show(getEditorFragment()).commit();
            mToolbar.setTitle(mActionBarTitleResId);
        }

@@ -387,16 +379,6 @@ public class ContactEditorActivity extends AppCompatContactsActivity implements
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        final View currentFocus = getCurrentFocus();
        if (imm != null && currentFocus != null) {
            imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
        }
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
Loading