Merge "Make FAB a direct child of CoordinatorLayout to fix its position." into sc-dev am: 20c969dcee
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Permission/+/15131560
Change-Id: I24454e1c86883aa6b651069842e3c1b498a5541b
diff --git a/PermissionController/res/layout-v31/permission_details_extended_fab.xml b/PermissionController/res/layout-v31/permission_details_extended_fab.xml
new file mode 100644
index 0000000..b3fa7d8
--- /dev/null
+++ b/PermissionController/res/layout-v31/permission_details_extended_fab.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2021 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.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/extended_fab"
+ android:theme="@style/Theme.MaterialComponents.DayNight"
+ android:visibility="gone"
+ style="@style/PermissionFrameExtendedFloatingActionButton" />
diff --git a/PermissionController/res/layout-v31/permissions_frame.xml b/PermissionController/res/layout-v31/permissions_frame.xml
deleted file mode 100644
index 1d962f4..0000000
--- a/PermissionController/res/layout-v31/permissions_frame.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2021 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:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <include layout="@layout/progress_header" />
-
- <androidx.coordinatorlayout.widget.CoordinatorLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:id="@+id/prefs_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <TextView
- android:id="@+id/no_permissions"
- style="@style/PermissionsFrameNoPermissionsText" />
-
- </LinearLayout>
-
- <include layout="@layout/loading_container" />
-
- <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
- android:id="@+id/extended_fab"
- android:theme="@style/Theme.MaterialComponents.DayNight"
- style="@style/PermissionFrameExtendedFloatingActionButton"
- android:visibility="gone" />
-
- </androidx.coordinatorlayout.widget.CoordinatorLayout>
-
-</LinearLayout>
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/debug/PermissionDetailsFragment.java b/PermissionController/src/com/android/permissioncontroller/permission/debug/PermissionDetailsFragment.java
index 61b1901..db9a797 100644
--- a/PermissionController/src/com/android/permissioncontroller/permission/debug/PermissionDetailsFragment.java
+++ b/PermissionController/src/com/android/permissioncontroller/permission/debug/PermissionDetailsFragment.java
@@ -42,6 +42,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
@@ -58,6 +59,8 @@
import com.android.permissioncontroller.permission.utils.KotlinUtils;
import com.android.permissioncontroller.permission.utils.Utils;
+import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
+
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
@@ -145,32 +148,32 @@
ViewGroup rootView = (ViewGroup) super.onCreateView(inflater, container,
savedInstanceState);
- if (mExtendedFab != null) {
- // Load the background tint color from the application theme
- // rather than the Material Design theme
- final int colorAccentTertiary = getContext().getColor(
- android.R.color.system_accent3_100);
- mExtendedFab.setBackgroundTintList(ColorStateList.valueOf(colorAccentTertiary));
+ PermissionDetailsWrapperFragment parentFragment = (PermissionDetailsWrapperFragment)
+ requireParentFragment();
+ CoordinatorLayout coordinatorLayout = parentFragment.getCoordinatorLayout();
+ inflater.inflate(R.layout.permission_details_extended_fab, coordinatorLayout);
+ ExtendedFloatingActionButton extendedFab = coordinatorLayout.requireViewById(
+ R.id.extended_fab);
+ // Load the background tint color from the application theme
+ // rather than the Material Design theme
+ final int colorAccentTertiary = getContext().getColor(
+ android.R.color.system_accent3_100);
+ extendedFab.setBackgroundTintList(ColorStateList.valueOf(colorAccentTertiary));
- mExtendedFab.setText(R.string.manage_permission);
- final boolean isDarkMode = (getActivity().getResources().getConfiguration().uiMode
- & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
- int textColor = isDarkMode ? android.R.attr.textColorPrimaryInverse
- : android.R.attr.textColorPrimary;
- TypedArray colorArray = getActivity().obtainStyledAttributes(
- new int[]{
- textColor
- }
- );
- mExtendedFab.setTextColor(colorArray.getColor(0, -1));
- mExtendedFab.setIcon(getActivity().getDrawable(R.drawable.ic_settings_outline));
- mExtendedFab.setVisibility(View.VISIBLE);
- mExtendedFab.setOnClickListener(v -> {
- Intent intent = new Intent(Intent.ACTION_MANAGE_PERMISSION_APPS)
- .putExtra(Intent.EXTRA_PERMISSION_NAME, mFilterGroup);
- startActivity(intent);
- });
- }
+ extendedFab.setText(R.string.manage_permission);
+ final boolean isDarkMode = (getActivity().getResources().getConfiguration().uiMode
+ & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
+ int textColor = isDarkMode ? android.R.attr.textColorPrimaryInverse
+ : android.R.attr.textColorPrimary;
+ TypedArray colorArray = getActivity().obtainStyledAttributes(new int[] { textColor });
+ extendedFab.setTextColor(colorArray.getColor(0, -1));
+ extendedFab.setIcon(getActivity().getDrawable(R.drawable.ic_settings_outline));
+ extendedFab.setVisibility(View.VISIBLE);
+ extendedFab.setOnClickListener(v -> {
+ Intent intent = new Intent(Intent.ACTION_MANAGE_PERMISSION_APPS)
+ .putExtra(Intent.EXTRA_PERMISSION_NAME, mFilterGroup);
+ startActivity(intent);
+ });
RecyclerView recyclerView = getListView();
int bottomPadding = getResources()
.getDimensionPixelSize(R.dimen.privhub_details_recycler_view_bottom_padding);
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/PermissionsFrameFragment.java b/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/PermissionsFrameFragment.java
index c7ccb4b..21c0d7b 100644
--- a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/PermissionsFrameFragment.java
+++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/PermissionsFrameFragment.java
@@ -28,7 +28,6 @@
import android.view.animation.AnimationUtils;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.preference.PreferenceFragmentCompat;
import androidx.recyclerview.widget.RecyclerView;
@@ -37,8 +36,6 @@
import com.android.permissioncontroller.permission.utils.Utils;
import com.android.settingslib.widget.ActionBarShadowController;
-import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
-
public abstract class PermissionsFrameFragment extends PreferenceFragmentCompat {
private static final String LOG_TAG = PermissionsFrameFragment.class.getSimpleName();
@@ -54,7 +51,6 @@
private View mProgressView;
private ViewGroup mPrefsView;
private boolean mIsLoading;
- @Nullable protected ExtendedFloatingActionButton mExtendedFab;
protected boolean mUseShadowController = true;
@@ -93,7 +89,6 @@
mPrefsView.addView(mPreferencesContainer, 0);
mProgressHeader = rootView.requireViewById(R.id.progress_bar_animation);
mProgressView = rootView.requireViewById(R.id.progress_bar_background);
- mExtendedFab = rootView.findViewById(R.id.extended_fab);
setProgressBarVisible(false);
getListView().setFocusable(false);
return rootView;