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

Commit 3ec7bad8 authored by SagarMakhar's avatar SagarMakhar Committed by Bruno Martins
Browse files

Use flow layout for advanced power menu as well



Change-Id: I62e46729278d57b8b21aa0c307f25d9ec053b216
Signed-off-by: default avatarSamarV-121 <samarvispute121@pm.me>
parent 683651e1
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
<?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.
-->
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/power_actions_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:background="@drawable/global_actions_lite_background"
    android:padding="@dimen/global_actions_lite_padding">

    <androidx.constraintlayout.helper.widget.Flow
          android:id="@+id/power_flow"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:flow_wrapMode="chain"
          app:flow_maxElementsWrap="2"
          app:flow_horizontalGap="@dimen/global_actions_lite_padding"
          app:flow_verticalGap="@dimen/global_actions_lite_padding"
          app:flow_horizontalStyle="packed"/>
</androidx.constraintlayout.widget.ConstraintLayout>
+1 −1
Original line number Diff line number Diff line
@@ -1585,7 +1585,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
                Log.w(TAG, "No power options action found at position: " + position);
                return null;
            }
            int viewLayoutResource = com.android.systemui.R.layout.global_actions_power_item;
            int viewLayoutResource = com.android.systemui.R.layout.global_actions_grid_item_lite;
            View view = convertView != null ? convertView
                    : LayoutInflater.from(mContext).inflate(viewLayoutResource, parent, false);
            view.setOnClickListener(v -> onClickItem(position));
+9 −2
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.view.Window;
import android.view.WindowManager;
import android.widget.ListAdapter;

import androidx.constraintlayout.helper.widget.Flow;

/**
 * Creates a customized Dialog for displaying the Shut Down and Restart actions.
 */
@@ -36,11 +38,15 @@ public class GlobalActionsPowerDialog {
     */
    public static Dialog create(@NonNull Context context, ListAdapter adapter) {
        ViewGroup listView = (ViewGroup) LayoutInflater.from(context).inflate(
                com.android.systemui.R.layout.global_actions_power_dialog, null);
                com.android.systemui.R.layout.global_actions_power_dialog_flow, null);

        Flow flow = listView.findViewById(com.android.systemui.R.id.power_flow);

        for (int i = 0; i < adapter.getCount(); i++) {
            View action = adapter.getView(i, null, listView);
            action.setId(View.generateViewId());
            listView.addView(action);
            flow.addView(action);
        }

        Resources res = context.getResources();
@@ -53,7 +59,8 @@ public class GlobalActionsPowerDialog {
        window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
        window.setTitle(""); // prevent Talkback from speaking first item name twice
        window.setBackgroundDrawable(res.getDrawable(
                com.android.systemui.R.drawable.control_background, context.getTheme()));
                com.android.systemui.R.drawable.global_actions_lite_background,
                context.getTheme()));
        window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

        return dialog;