Merge "Create 2 pane layout for large screen displays."

This commit is contained in:
TreeHugger Robot
2020-12-10 19:12:21 +00:00
committed by Android (Google) Code Review
11 changed files with 252 additions and 38 deletions

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2020 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/global_actions_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_width="0dp"
android:clipChildren="false"
android:orientation="vertical"
android:clipToPadding="false"
android:id="@+id/controls_pane"
>
<LinearLayout
android:id="@+id/global_actions_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_width="0dp"
android:orientation="vertical"
android:id="@+id/nfc_pane"
>
<include layout="@layout/global_actions_view" />
<include layout="@layout/global_actions_lock_view" />
<LinearLayout
android:id="@+id/global_actions_grid_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:orientation="vertical"
android:clipToPadding="false">
<FrameLayout
android:id="@+id/global_actions_wallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,30 @@
<!--
~ Copyright (C) 2020 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<com.android.systemui.globalactions.MinHeightScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="none">
<LinearLayout
android:id="@+id/global_actions_controls_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="@dimen/global_actions_side_margin"
android:layout_marginRight="@dimen/global_actions_side_margin" />
</com.android.systemui.globalactions.MinHeightScrollView>

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2020 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/global_actions_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/nfc_pane"
>
<include layout="@layout/global_actions_view" />
<include layout="@layout/global_actions_lock_view" />
<com.android.systemui.globalactions.MinHeightScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="none">
<LinearLayout
android:id="@+id/global_actions_grid_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:orientation="vertical"
android:clipToPadding="false">
<FrameLayout
android:id="@+id/global_actions_wallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</com.android.systemui.globalactions.MinHeightScrollView>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/controls_pane"
android:clipToPadding="false"
android:clipChildren="false">
<LinearLayout
android:id="@+id/global_actions_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</LinearLayout>
</LinearLayout>

View File

@@ -58,11 +58,5 @@
android:background="?android:attr/selectableItemBackgroundBorderless" />
</LinearLayout>
<LinearLayout
android:id="@+id/global_actions_controls_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="@dimen/global_actions_side_margin"
android:layout_marginRight="@dimen/global_actions_side_margin" />
<include layout="@layout/global_actions_controls_list_view" />
</merge>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/global_actions_controls_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="@dimen/global_actions_side_margin"
android:layout_marginRight="@dimen/global_actions_side_margin" />

View File

@@ -18,7 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="98dp"
android:layout_height="@dimen/global_actions_grid_item_layout_height"
android:gravity="bottom|center_horizontal"
android:orientation="vertical"
android:paddingTop="12dp"

View File

@@ -32,4 +32,7 @@
<!-- orientation of the dead zone when touches have recently occurred elsewhere on screen -->
<integer name="navigation_bar_deadzone_orientation">0</integer>
<!-- Whether wallet view is shown in landscape / seascape orientations -->
<bool name="global_actions_show_landscape_wallet_view">true</bool>
</resources>

View File

@@ -94,4 +94,11 @@
<!-- Text size for user name in user switcher -->
<dimen name="kg_user_switcher_text_size">18sp</dimen>
<!-- TODO(himanshujaju) - add comments -->
<dimen name="global_actions_wallet_top_margin">5dp</dimen>
<dimen name="controls_header_bottom_margin">12dp</dimen>
<dimen name="controls_top_margin">24dp</dimen>
<dimen name="global_actions_grid_item_layout_height">80dp</dimen>
</resources>

View File

@@ -570,4 +570,7 @@
<bool name="config_showNotificationForUnknownBatteryState">false</bool>
<!-- content URL in a notification when ACTION_BATTERY_CHANGED.EXTRA_PRESENT field is false -->
<string translatable="false" name="config_batteryStateUnknownUrl"></string>
<!-- Whether wallet view is shown in landscape / seascape orientations -->
<bool name="global_actions_show_landscape_wallet_view">false</bool>
</resources>

View File

@@ -1005,6 +1005,7 @@
<dimen name="global_actions_grid_vertical_padding">3dp</dimen>
<dimen name="global_actions_grid_horizontal_padding">3dp</dimen>
<dimen name="global_actions_grid_item_layout_height">98dp</dimen>
<dimen name="global_actions_grid_item_side_margin">5dp</dimen>
<dimen name="global_actions_grid_item_vertical_margin">4dp</dimen>
<dimen name="global_actions_grid_item_width">64dp</dimen>

View File

@@ -50,6 +50,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.UserInfo;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.graphics.Color;
@@ -256,6 +257,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
private UserContextProvider mUserContextProvider;
@VisibleForTesting
boolean mShowLockScreenCardsAndControls = false;
private int mSmallestScreenWidthDp;
@VisibleForTesting
public enum GlobalActionsEvent implements UiEventLogger.UiEventEnum {
@@ -344,6 +346,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
mSysUiState = sysUiState;
mMainHandler = handler;
mUserContextProvider = userContextProvider;
mSmallestScreenWidthDp = mContext.getResources().getConfiguration().smallestScreenWidthDp;
// receive broadcasts
IntentFilter filter = new IntentFilter();
@@ -760,6 +763,15 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
}
}
@Override
public void onConfigChanged(Configuration newConfig) {
if (mDialog != null && mDialog.isShowing()
&& (newConfig.smallestScreenWidthDp != mSmallestScreenWidthDp)) {
mSmallestScreenWidthDp = newConfig.smallestScreenWidthDp;
mDialog.refreshDialog();
}
}
public void destroy() {
mConfigurationController.removeCallback(this);
}
@@ -2230,6 +2242,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
return;
}
boolean isLandscapeWalletViewShown = mContext.getResources().getBoolean(
com.android.systemui.R.bool.global_actions_show_landscape_wallet_view);
int rotation = RotationUtils.getRotation(mContext);
boolean rotationLocked = RotationPolicy.isRotationLocked(mContext);
if (rotation != RotationUtils.ROTATION_NONE) {
@@ -2246,6 +2261,10 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
mGlobalActionsLayout.post(() ->
RotationPolicy.setRotationLockAtAngle(
mContext, false, RotationUtils.ROTATION_NONE));
if (!isLandscapeWalletViewShown) {
return;
}
}
} else {
if (!rotationLocked) {
@@ -2253,44 +2272,48 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
mResetOrientationData = new ResetOrientationData();
mResetOrientationData.locked = false;
}
}
// Lock to portrait, so the user doesn't accidentally hide the panel.
boolean shouldLockRotation = !isLandscapeWalletViewShown;
if (rotationLocked != shouldLockRotation) {
// Locks the screen to portrait if the landscape / seascape orientation does not
// show the wallet view, so the user doesn't accidentally hide the panel.
// This call is posted so that the rotation does not change until post-layout,
// otherwise onConfigurationChanged() may not get invoked.
mGlobalActionsLayout.post(() ->
RotationPolicy.setRotationLockAtAngle(
mContext, true, RotationUtils.ROTATION_NONE));
mContext, shouldLockRotation, RotationUtils.ROTATION_NONE));
}
}
// Disable rotation suggestions, if enabled
setRotationSuggestionsEnabled(false);
// Disable rotation suggestions, if enabled
setRotationSuggestionsEnabled(false);
FrameLayout panelContainer =
findViewById(com.android.systemui.R.id.global_actions_wallet);
FrameLayout.LayoutParams panelParams =
new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
if (!mControlsAvailable) {
panelParams.topMargin = mContext.getResources().getDimensionPixelSize(
com.android.systemui.R.dimen.global_actions_wallet_top_margin);
}
View walletView = mWalletViewController.getPanelContent();
panelContainer.addView(walletView, panelParams);
// Smooth transitions when wallet is resized, which can happen when a card is added
ViewGroup root = findViewById(com.android.systemui.R.id.global_actions_grid_root);
if (root != null) {
walletView.addOnLayoutChangeListener((v, l, t, r, b, ol, ot, or, ob) -> {
int oldHeight = ob - ot;
int newHeight = b - t;
if (oldHeight > 0 && oldHeight != newHeight) {
TransitionSet transition = new AutoTransition()
.setDuration(250)
.setOrdering(TransitionSet.ORDERING_TOGETHER);
TransitionManager.beginDelayedTransition(root, transition);
}
});
}
FrameLayout panelContainer =
findViewById(com.android.systemui.R.id.global_actions_wallet);
FrameLayout.LayoutParams panelParams =
new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
if (!mControlsAvailable) {
panelParams.topMargin = mContext.getResources().getDimensionPixelSize(
com.android.systemui.R.dimen.global_actions_wallet_top_margin);
}
View walletView = mWalletViewController.getPanelContent();
panelContainer.addView(walletView, panelParams);
// Smooth transitions when wallet is resized, which can happen when a card is added
ViewGroup root = findViewById(com.android.systemui.R.id.global_actions_grid_root);
if (root != null) {
walletView.addOnLayoutChangeListener((v, l, t, r, b, ol, ot, or, ob) -> {
int oldHeight = ob - ot;
int newHeight = b - t;
if (oldHeight > 0 && oldHeight != newHeight) {
TransitionSet transition = new AutoTransition()
.setDuration(250)
.setOrdering(TransitionSet.ORDERING_TOGETHER);
TransitionManager.beginDelayedTransition(root, transition);
}
});
}
}