summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tony Huang <tonyychuang@google.com> 2019-05-02 16:51:01 +0800
committer Tony Huang <tonyychuang@google.com> 2019-05-23 19:09:36 +0800
commitf7b05c4708f02f59ef5a1b70278d2d6ad0dda8bb (patch)
tree42a0b1c259941138a4512be9cbf8ab29ea3f15a9
parent97ce4ce55fb86bd643247fa9dae070bb629579c5 (diff)
Update layout for gesture navigation
By request of gesture navigation, apps need make their contents extand to nav bar and update nav bar color to transparent using run time code to avoid RRO overwrite. Refactor layout and add padding for some layout to avoid some UI pop up nav bar or status bar position. Bug: 127822515 Test: visual Test: DocumentsUIGoogleTests Change-Id: I8a7fcdfd83734084ed34228c2b20c31bdcbda394
-rw-r--r--res/layout/drawer_layout.xml4
-rw-r--r--res/layout/fixed_layout.xml4
-rw-r--r--res/layout/fragment_pick.xml2
-rw-r--r--res/layout/fragment_save.xml3
-rw-r--r--res/layout/inspector_activity.xml7
-rw-r--r--res/values-night/colors.xml1
-rw-r--r--res/values/colors.xml1
-rw-r--r--res/values/themes.xml1
-rw-r--r--src/com/android/documentsui/BaseActivity.java30
-rw-r--r--src/com/android/documentsui/files/FilesActivity.java6
-rw-r--r--src/com/android/documentsui/inspector/InspectorActivity.java30
-rw-r--r--src/com/android/documentsui/picker/PickActivity.java7
-rw-r--r--src/com/android/documentsui/ui/Snackbars.java7
-rw-r--r--tests/functional/com/android/documentsui/BandSelectionUiTest.java10
-rw-r--r--tests/functional/com/android/documentsui/ContextMenuUiTest.java7
15 files changed, 97 insertions, 23 deletions
diff --git a/res/layout/drawer_layout.xml b/res/layout/drawer_layout.xml
index 0b8aff47a..a5331d520 100644
--- a/res/layout/drawer_layout.xml
+++ b/res/layout/drawer_layout.xml
@@ -61,12 +61,12 @@
android:layout_height="match_parent"/>
</FrameLayout>
- <FrameLayout
+ <androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/container_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
- android:background="?android:attr/colorBackground"
+ android:background="?android:attr/colorBackgroundFloating"
android:elevation="8dp" />
<include layout="@layout/directory_app_bar"/>
diff --git a/res/layout/fixed_layout.xml b/res/layout/fixed_layout.xml
index 2a4591047..7f7547fd4 100644
--- a/res/layout/fixed_layout.xml
+++ b/res/layout/fixed_layout.xml
@@ -88,11 +88,11 @@
android:layout_height="0dp"
android:layout_weight="1" />
- <FrameLayout
+ <androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/container_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/colorBackground"
+ android:background="?android:attr/colorBackgroundFloating"
android:elevation="8dp" />
</LinearLayout>
diff --git a/res/layout/fragment_pick.xml b/res/layout/fragment_pick.xml
index 7b70de6c8..c18afa0b3 100644
--- a/res/layout/fragment_pick.xml
+++ b/res/layout/fragment_pick.xml
@@ -16,7 +16,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="@dimen/bottom_bar_height"
+ android:layout_height="wrap_content"
android:orientation="horizontal"
android:baselineAligned="false"
android:gravity="center_vertical|end"
diff --git a/res/layout/fragment_save.xml b/res/layout/fragment_save.xml
index 4c8132b6d..b3f3c0b4c 100644
--- a/res/layout/fragment_save.xml
+++ b/res/layout/fragment_save.xml
@@ -16,13 +16,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="@dimen/bottom_bar_height"
+ android:layout_height="wrap_content"
android:paddingStart="@dimen/list_item_padding"
android:paddingEnd="@dimen/bottom_bar_padding"
android:orientation="horizontal"
android:baselineAligned="false"
android:gravity="center_vertical"
- android:fitsSystemWindows="true"
android:minHeight="?android:attr/listPreferredItemHeightSmall">
<FrameLayout
diff --git a/res/layout/inspector_activity.xml b/res/layout/inspector_activity.xml
index 0467fa527..df28d4968 100644
--- a/res/layout/inspector_activity.xml
+++ b/res/layout/inspector_activity.xml
@@ -19,21 +19,18 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/inspector_root"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fitsSystemWindows="true">
+ android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:fitsSystemWindows="true"
android:background="?android:colorBackground">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/actionBarSize"
- android:fitsSystemWindows="true"
app:titleEnabled="false"
app:statusBarScrim="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
@@ -71,10 +68,12 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:overScrollMode="never"
app:behavior_overlapTop="10dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
+ android:id="@+id/inspector_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 36c092201..f358b023a 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -16,6 +16,7 @@
<resources>
<color name="app_background_color">#202124</color>
<color name="background_floating">#3C4043</color>
+ <color name="nav_bar_translucent">#52000000</color>
<color name="primary">#8AB4F8</color>
<color name="secondary">#3D8AB4F8</color>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index a5bcf4ccd..a34f09d2b 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -21,6 +21,7 @@
<color name="app_background_color">@android:color/white</color>
<color name="background_floating">@android:color/white</color>
+ <color name="nav_bar_translucent">#99FFFFFF</color>
<color name="primary">#1E88E5</color> <!-- Blue 600 -->
<color name="secondary">#E3F2FD</color> <!-- Blue 50 -->
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 66677934c..971fa1f0d 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -35,7 +35,6 @@
<item name="android:listDivider">@drawable/list_divider</item>
<item name="android:statusBarColor">?android:colorBackground</item>
<item name="android:navigationBarColor">?android:colorBackground</item>
- <item name="android:navigationBarDividerColor">@color/hairline</item>
<item name="android:windowBackground">?android:colorBackground</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar">true</item>
diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java
index 9b783a8c0..9954e9d0e 100644
--- a/src/com/android/documentsui/BaseActivity.java
+++ b/src/com/android/documentsui/BaseActivity.java
@@ -24,7 +24,9 @@ import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
+import android.graphics.Color;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.os.MessageQueue.IdleHandler;
import android.preference.PreferenceManager;
@@ -145,6 +147,8 @@ public abstract class BaseActivity
setContentView(mLayoutId);
+ setContainer();
+
mInjector = getInjector();
mState = getState(icicle);
mDrawer = DrawerController.create(this, mInjector.config);
@@ -370,6 +374,32 @@ public abstract class BaseActivity
return state;
}
+ private void setContainer() {
+ View root = findViewById(R.id.coordinator_layout);
+ root.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+ root.setOnApplyWindowInsetsListener((v, insets) -> {
+ root.setPadding(insets.getSystemWindowInsetLeft(),
+ insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), 0);
+
+ View saveContainer = findViewById(R.id.container_save);
+ saveContainer.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom());
+
+ View rootsContainer = findViewById(R.id.container_roots);
+ rootsContainer.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom());
+
+ return insets.consumeSystemWindowInsets();
+ });
+
+ getWindow().setNavigationBarDividerColor(Color.TRANSPARENT);
+ if (Build.VERSION.SDK_INT >= 29) {
+ getWindow().setNavigationBarColor(Color.TRANSPARENT);
+ getWindow().setNavigationBarContrastEnforced(true);
+ } else {
+ getWindow().setNavigationBarColor(getColor(R.color.nav_bar_translucent));
+ }
+ }
+
@Override
public void setRootsDrawerOpen(boolean open) {
mNavigator.revealRootsDrawer(open);
diff --git a/src/com/android/documentsui/files/FilesActivity.java b/src/com/android/documentsui/files/FilesActivity.java
index 297a3f3a2..d93e5dbac 100644
--- a/src/com/android/documentsui/files/FilesActivity.java
+++ b/src/com/android/documentsui/files/FilesActivity.java
@@ -20,12 +20,14 @@ import static com.android.documentsui.OperationDialogFragment.DIALOG_TYPE_UNKNOW
import android.app.ActivityManager.TaskDescription;
import android.content.Intent;
+import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.KeyboardShortcutGroup;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import androidx.annotation.CallSuper;
import androidx.fragment.app.FragmentManager;
@@ -171,6 +173,10 @@ public class FilesActivity extends BaseActivity implements ActionHandler.Addons
updateTaskDescription(intent);
}
+ // Set save container background to transparent for edge to edge nav bar.
+ View saveContainer = findViewById(R.id.container_save);
+ saveContainer.setBackgroundColor(Color.TRANSPARENT);
+
presentFileErrors(icicle, intent);
}
diff --git a/src/com/android/documentsui/inspector/InspectorActivity.java b/src/com/android/documentsui/inspector/InspectorActivity.java
index e9b872abf..f7c2c8de5 100644
--- a/src/com/android/documentsui/inspector/InspectorActivity.java
+++ b/src/com/android/documentsui/inspector/InspectorActivity.java
@@ -18,7 +18,9 @@ package com.android.documentsui.inspector;
import static androidx.core.util.Preconditions.checkArgument;
import android.content.Intent;
+import android.graphics.Color;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
@@ -48,13 +50,14 @@ public class InspectorActivity extends AppCompatActivity {
setContentView(R.layout.inspector_activity);
+ setContainer();
+
mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final DataSupplier loader = new RuntimeDataSupplier(this, LoaderManager.getInstance(this));
- mView = findViewById(R.id.inspector_root);
mController = new InspectorController(this, loader, mView,
getIntent().getStringExtra(Intent.EXTRA_TITLE),
getIntent().getBooleanExtra(Shared.EXTRA_SHOW_DEBUG, false));
@@ -83,4 +86,27 @@ public class InspectorActivity extends AppCompatActivity {
}
return super.onOptionsItemSelected(item);
}
-}
+
+ private void setContainer() {
+ mView = findViewById(R.id.inspector_root);
+ mView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+ mView.setOnApplyWindowInsetsListener((v, insets) -> {
+ mView.setPadding(insets.getSystemWindowInsetLeft(),
+ insets.getSystemWindowInsetTop(),
+ insets.getSystemWindowInsetRight(), 0);
+
+ View container = findViewById(R.id.inspector_container);
+ container.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom());
+ return insets;
+ });
+
+ getWindow().setNavigationBarDividerColor(Color.TRANSPARENT);
+ if (Build.VERSION.SDK_INT >= 29) {
+ getWindow().setNavigationBarColor(Color.TRANSPARENT);
+ getWindow().setNavigationBarContrastEnforced(true);
+ } else {
+ getWindow().setNavigationBarColor(getColor(R.color.nav_bar_translucent));
+ }
+ }
+} \ No newline at end of file
diff --git a/src/com/android/documentsui/picker/PickActivity.java b/src/com/android/documentsui/picker/PickActivity.java
index aece47b03..57969e0c2 100644
--- a/src/com/android/documentsui/picker/PickActivity.java
+++ b/src/com/android/documentsui/picker/PickActivity.java
@@ -23,6 +23,7 @@ import static com.android.documentsui.base.State.ACTION_OPEN_TREE;
import static com.android.documentsui.base.State.ACTION_PICK_COPY_DESTINATION;
import android.content.Intent;
+import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
@@ -30,6 +31,7 @@ import android.provider.DocumentsContract;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import androidx.annotation.CallSuper;
import androidx.fragment.app.Fragment;
@@ -187,6 +189,11 @@ public class PickActivity extends BaseActivity implements ActionHandler.Addons {
} else if (mState.action == ACTION_OPEN_TREE ||
mState.action == ACTION_PICK_COPY_DESTINATION) {
PickFragment.show(getSupportFragmentManager());
+ } else {
+ // If PickFragment or SaveFragment does not show,
+ // Set save container background to transparent for edge to edge nav bar.
+ View saveContainer = findViewById(R.id.container_save);
+ saveContainer.setBackgroundColor(Color.TRANSPARENT);
}
if (mState.action == ACTION_GET_CONTENT) {
diff --git a/src/com/android/documentsui/ui/Snackbars.java b/src/com/android/documentsui/ui/Snackbars.java
index c3f631534..5d6e012e8 100644
--- a/src/com/android/documentsui/ui/Snackbars.java
+++ b/src/com/android/documentsui/ui/Snackbars.java
@@ -16,17 +16,18 @@
package com.android.documentsui.ui;
-import androidx.annotation.StringRes;
import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
-import com.google.android.material.snackbar.Snackbar;
+import androidx.annotation.StringRes;
import com.android.documentsui.R;
import com.android.documentsui.base.Shared;
+import com.google.android.material.snackbar.Snackbar;
+
import java.util.function.Consumer;
public final class Snackbars {
@@ -109,7 +110,7 @@ public final class Snackbars {
public static final Snackbar makeSnackbar(
Activity activity, CharSequence message, int duration) {
- final View view = activity.findViewById(R.id.coordinator_layout);
+ final View view = activity.findViewById(R.id.container_save);
return Snackbar.make(view, message, duration);
}
}
diff --git a/tests/functional/com/android/documentsui/BandSelectionUiTest.java b/tests/functional/com/android/documentsui/BandSelectionUiTest.java
index a7eab63de..94cdef351 100644
--- a/tests/functional/com/android/documentsui/BandSelectionUiTest.java
+++ b/tests/functional/com/android/documentsui/BandSelectionUiTest.java
@@ -40,8 +40,9 @@ public class BandSelectionUiTest extends ActivityTest<FilesActivity> {
public void testBandSelection_allFiles() throws Exception {
bots.main.switchToGridMode();
Rect dirListBounds = bots.directory.findDocumentsList().getBounds();
- Point start = new Point(dirListBounds.right - 1, dirListBounds.bottom - 1);
- Point end = new Point(dirListBounds.left + 1, dirListBounds.top + 1);
+ Rect startDir = bots.directory.findDocument(dirName1).getBounds();
+ Point start = new Point(dirListBounds.right - 1, startDir.centerY());
+ Point end = new Point(dirListBounds.left + 1, dirListBounds.bottom - 1);
bots.gesture.bandSelection(start, end);
bots.directory.assertSelection(4);
@@ -50,9 +51,10 @@ public class BandSelectionUiTest extends ActivityTest<FilesActivity> {
public void testBandSelection_someFiles() throws Exception {
bots.main.switchToGridMode();
Rect dirListBounds = bots.directory.findDocumentsList().getBounds();
+ Rect startDoc = bots.directory.findDocument(fileNameNoRename).getBounds();
Rect endDoc = bots.directory.findDocument(fileName1).getBounds();
- // Start from list right bottom.
- Point start = new Point(dirListBounds.right - 1, dirListBounds.bottom - 1);
+ // Start from right side of file NoRename.
+ Point start = new Point(dirListBounds.right - 1, startDoc.bottom - 1);
// End is center of file1
Point end = new Point(endDoc.centerX(), endDoc.centerY());
bots.gesture.bandSelection(start, end);
diff --git a/tests/functional/com/android/documentsui/ContextMenuUiTest.java b/tests/functional/com/android/documentsui/ContextMenuUiTest.java
index eb0653865..8032240f8 100644
--- a/tests/functional/com/android/documentsui/ContextMenuUiTest.java
+++ b/tests/functional/com/android/documentsui/ContextMenuUiTest.java
@@ -109,8 +109,11 @@ public class ContextMenuUiTest extends ActivityTest<FilesActivity> {
menuItems.put("Paste", true);
menuItems.put("New folder", true);
Rect dirListBounds = bots.directory.findDocumentsList().getBounds();
- bots.directory.rightClickDocument(
- new Point(dirListBounds.right - 1, dirListBounds.bottom - 1)); //bottom right corner
+ Rect dirBounds = bots.directory.findDocument(dirName1).getBounds();
+
+ bots.main.switchToGridMode();
+ // right side of dir1 area
+ bots.directory.rightClickDocument(new Point(dirListBounds.right - 1, dirBounds.centerY()));
bots.menu.assertPresentMenuItems(menuItems);
}
}