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

Commit 5980354d authored by Brian Isganitis's avatar Brian Isganitis Committed by Automerger Merge Worker
Browse files

Show toolbar back button on subsettings pages am: 6afcfd7c

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14741513

Change-Id: I5521e29757bb7bf7d0fb8d0774ae84776abb4ba7
parents 24cee4fb 6afcfd7c
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasExtra;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasExtra;
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static androidx.test.espresso.matcher.ViewMatchers.withText;


@@ -109,6 +110,7 @@ public class SettingsActivityTest {


        onView(withText("About")).check(matches(isDisplayed()));
        onView(withText("About")).check(matches(isDisplayed()));
        onView(withText("Version")).check(matches(isDisplayed()));
        onView(withText("Version")).check(matches(isDisplayed()));
        onView(withContentDescription("Navigate up")).check(matches(isDisplayed()));
    }
    }


    @Test
    @Test
@@ -119,6 +121,7 @@ public class SettingsActivityTest {


        onView(withText("Developer Options")).check(matches(isDisplayed()));
        onView(withText("Developer Options")).check(matches(isDisplayed()));
        onView(withId(R.id.filter_box)).check(matches(isDisplayed()));
        onView(withId(R.id.filter_box)).check(matches(isDisplayed()));
        onView(withContentDescription("Navigate up")).check(matches(isDisplayed()));
    }
    }


    @Test
    @Test
@@ -134,4 +137,16 @@ public class SettingsActivityTest {
            assertThat(e.getMessage()).contains(fragmentClass);
            assertThat(e.getMessage()).contains(fragmentClass);
        }
        }
    }
    }

    @Test
    public void testSettings_backButtonFinishesActivity() {
        Bundle fragmentArgs = new Bundle();
        fragmentArgs.putString(ARG_PREFERENCE_ROOT, "about_screen");
        Intent intent = new Intent(mApplicationContext, SettingsActivity.class)
                .putExtra(EXTRA_FRAGMENT_ARGS, fragmentArgs);
        ActivityScenario<SettingsActivity> scenario = ActivityScenario.launch(intent);

        onView(withContentDescription("Navigate up")).perform(click());
        scenario.onActivity(activity -> assertThat(activity.isFinishing()).isTrue());
    }
}
}
+15 −1
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Bundle;
import android.text.TextUtils;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.view.View;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
@@ -86,8 +87,12 @@ public class SettingsActivity extends FragmentActivity
        setActionBar(findViewById(R.id.action_bar));
        setActionBar(findViewById(R.id.action_bar));
        WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
        WindowCompat.setDecorFitsSystemWindows(getWindow(), false);


        if (savedInstanceState == null) {
        Intent intent = getIntent();
        Intent intent = getIntent();
        if (intent.hasExtra(EXTRA_FRAGMENT) || intent.hasExtra(EXTRA_FRAGMENT_ARGS)) {
            getActionBar().setDisplayHomeAsUpEnabled(true);
        }

        if (savedInstanceState == null) {
            Bundle args = intent.getBundleExtra(EXTRA_FRAGMENT_ARGS);
            Bundle args = intent.getBundleExtra(EXTRA_FRAGMENT_ARGS);
            if (args == null) {
            if (args == null) {
                args = new Bundle();
                args = new Bundle();
@@ -164,6 +169,15 @@ public class SettingsActivity extends FragmentActivity
        return startPreference(getString(R.string.settings_fragment_name), args, pref.getKey());
        return startPreference(getString(R.string.settings_fragment_name), args, pref.getKey());
    }
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            onBackPressed();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
    /**
     * This fragment shows the launcher preferences.
     * This fragment shows the launcher preferences.
     */
     */