Merge changes I7b9e6e7f,I9729cd40 into sc-dev
* changes:
2/ Notify adjust touch slop when one handed mode activated
1/ Provides feasibility to adjust touch slop in TouchController
diff --git a/res/layout/settings_activity.xml b/res/layout/settings_activity.xml
index c70d5bf..5edd2df 100644
--- a/res/layout/settings_activity.xml
+++ b/res/layout/settings_activity.xml
@@ -18,7 +18,8 @@
android:id="@+id/content_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:fitsSystemWindows="true">
<Toolbar
android:id="@+id/action_bar"
diff --git a/robolectric_tests/src/com/android/launcher3/settings/SettingsActivityTest.java b/robolectric_tests/src/com/android/launcher3/settings/SettingsActivityTest.java
index 85bf28e..3271812 100644
--- a/robolectric_tests/src/com/android/launcher3/settings/SettingsActivityTest.java
+++ b/robolectric_tests/src/com/android/launcher3/settings/SettingsActivityTest.java
@@ -27,6 +27,7 @@
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasExtra;
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
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.withText;
@@ -109,6 +110,7 @@
onView(withText("About")).check(matches(isDisplayed()));
onView(withText("Version")).check(matches(isDisplayed()));
+ onView(withContentDescription("Navigate up")).check(matches(isDisplayed()));
}
@Test
@@ -119,6 +121,7 @@
onView(withText("Developer Options")).check(matches(isDisplayed()));
onView(withId(R.id.filter_box)).check(matches(isDisplayed()));
+ onView(withContentDescription("Navigate up")).check(matches(isDisplayed()));
}
@Test
@@ -134,4 +137,16 @@
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());
+ }
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index cdc09f1..e9245b0 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -399,8 +399,10 @@
public boolean shouldInsetWidgets() {
Rect widgetPadding = inv.defaultWidgetPadding;
- // Check all sides to ensure that the widget won't overlap into another cell.
- return cellLayoutBorderSpacingPx > widgetPadding.left
+ // Check all sides to ensure that the widget won't overlap into another cell, or into
+ // status bar.
+ return workspaceTopPadding > widgetPadding.top
+ && cellLayoutBorderSpacingPx > widgetPadding.left
&& cellLayoutBorderSpacingPx > widgetPadding.top
&& cellLayoutBorderSpacingPx > widgetPadding.right
&& cellLayoutBorderSpacingPx > widgetPadding.bottom;
diff --git a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
index e2a69ff..8fe42ac 100644
--- a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
+++ b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
@@ -152,6 +152,17 @@
filterPreferences(query, mPreferenceScreen);
}
});
+
+ View listView = getListView();
+ final int bottomPadding = listView.getPaddingBottom();
+ listView.setOnApplyWindowInsetsListener((v, insets) -> {
+ v.setPadding(
+ v.getPaddingLeft(),
+ v.getPaddingTop(),
+ v.getPaddingRight(),
+ bottomPadding + insets.getSystemWindowInsetBottom());
+ return insets.consumeSystemWindowInsets();
+ });
}
@Override
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java
index 05927ef..915e140 100644
--- a/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/src/com/android/launcher3/settings/SettingsActivity.java
@@ -24,9 +24,12 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
+import android.view.MenuItem;
+import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
+import androidx.core.view.WindowCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@@ -82,9 +85,14 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
setActionBar(findViewById(R.id.action_bar));
+ WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
+
+ Intent intent = getIntent();
+ if (intent.hasExtra(EXTRA_FRAGMENT) || intent.hasExtra(EXTRA_FRAGMENT_ARGS)) {
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ }
if (savedInstanceState == null) {
- Intent intent = getIntent();
Bundle args = intent.getBundleExtra(EXTRA_FRAGMENT_ARGS);
if (args == null) {
args = new Bundle();
@@ -161,6 +169,15 @@
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.
*/
@@ -199,6 +216,21 @@
}
@Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ View listView = getListView();
+ final int bottomPadding = listView.getPaddingBottom();
+ listView.setOnApplyWindowInsetsListener((v, insets) -> {
+ v.setPadding(
+ v.getPaddingLeft(),
+ v.getPaddingTop(),
+ v.getPaddingRight(),
+ bottomPadding + insets.getSystemWindowInsetBottom());
+ return insets.consumeSystemWindowInsets();
+ });
+ }
+
+ @Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(SAVE_HIGHLIGHTED_KEY, mPreferenceHighlighted);