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

Commit a714a734 authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Update custom widget layouts to have a restricted icon." into nyc-dev

parents cc524096 a5963510
Loading
Loading
Loading
Loading
+0 −57
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 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.
-->

<!-- Used by UserPreference to show the trash icon -->
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="horizontal">
    <View
        android:id="@+id/divider_manage"
        android:layout_width="2dip"
        android:layout_height="match_parent"
        android:layout_marginTop="5dip"
        android:layout_marginBottom="5dip"
        android:background="@android:drawable/divider_horizontal_dark" />
    <ImageView
        android:id="@+id/manage_user"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:paddingStart="16dip"
        android:paddingEnd="16dip"
        android:src="@drawable/ic_sysbar_quicksettings"
        android:contentDescription="@string/settings_label"
        android:layout_gravity="center"
        android:background="?android:attr/selectableItemBackground" />
    <View
        android:id="@+id/divider_delete"
        android:layout_width="2dip"
        android:layout_height="match_parent"
        android:layout_marginTop="5dip"
        android:layout_marginBottom="5dip"
        android:background="@android:drawable/divider_horizontal_dark" />
    <ImageView
        android:id="@+id/trash_user"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:paddingStart="16dip"
        android:paddingEnd="16dip"
        android:src="@drawable/ic_menu_delete"
        android:contentDescription="@string/user_delete_user_description"
        android:layout_gravity="center"
        android:background="?android:attr/selectableItemBackground" />
</LinearLayout>
+20 −8
Original line number Diff line number Diff line
@@ -30,14 +30,26 @@
        android:layout_marginTop="8dip"
        android:layout_marginBottom="8dip">

        <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
            <TextView android:id="@android:id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:singleLine="true"
                android:textAppearance="@android:style/TextAppearance.Material.Subhead"
                android:textColor="?android:attr/textColorPrimary"
                android:ellipsize="marquee"
                android:fadingEdge="horizontal" />
            <!-- Preference should place its actual preference widget here. -->
            <LinearLayout android:id="@android:id/widget_frame"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="end|center_vertical"
                android:paddingStart="16dp"
                android:orientation="vertical" />
        </LinearLayout>

        <FrameLayout
            android:layout_width="match_parent"
+60 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->

<!-- Used by UserPreference to show the trash icon -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <include layout="@layout/restricted_icon" />

    <LinearLayout android:id="@+id/user_delete_widget"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal">
        <View
            android:id="@+id/divider_manage"
            android:layout_width="2dip"
            android:layout_height="match_parent"
            android:layout_marginTop="5dip"
            android:layout_marginBottom="5dip"
            android:background="@android:drawable/divider_horizontal_dark" />
        <ImageView
            android:id="@+id/manage_user"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:paddingStart="16dip"
            android:paddingEnd="16dip"
            android:src="@drawable/ic_sysbar_quicksettings"
            android:contentDescription="@string/settings_label"
            android:layout_gravity="center"
            android:background="?android:attr/selectableItemBackground" />
        <View
            android:id="@+id/divider_delete"
            android:layout_width="2dip"
            android:layout_height="match_parent"
            android:layout_marginTop="5dip"
            android:layout_marginBottom="5dip"
            android:background="@android:drawable/divider_horizontal_dark" />
        <ImageView
            android:id="@+id/trash_user"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:paddingStart="16dip"
            android:paddingEnd="16dip"
            android:src="@drawable/ic_menu_delete"
            android:contentDescription="@string/user_delete_user_description"
            android:layout_gravity="center"
            android:background="?android:attr/selectableItemBackground" />
    </LinearLayout>
</merge>
 No newline at end of file
+32 −27
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class UserPreference extends RestrictedPreference {
            OnClickListener deleteListener) {
        super(context, attrs);
        if (deleteListener != null || settingsListener != null) {
            setWidgetLayoutResource(R.layout.preference_user_delete_widget);
            setWidgetLayoutResource(R.layout.restricted_preference_user_delete_widget);
        }
        mDeleteClickListener = deleteListener;
        mSettingsClickListener = settingsListener;
@@ -89,6 +89,14 @@ public class UserPreference extends RestrictedPreference {

    @Override
    public void onBindViewHolder(PreferenceViewHolder view) {
        super.onBindViewHolder(view);
        final boolean disabledByAdmin = isDisabledByAdmin();
        dimIcon(disabledByAdmin);
        View userDeleteWidget = view.findViewById(R.id.user_delete_widget);
        if (userDeleteWidget != null) {
            userDeleteWidget.setVisibility(disabledByAdmin ? View.GONE : View.VISIBLE);
        }
        if (!disabledByAdmin) {
            UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
            View deleteDividerView = view.findViewById(R.id.divider_delete);
            View manageDividerView = view.findViewById(R.id.divider_manage);
@@ -103,7 +111,6 @@ public class UserPreference extends RestrictedPreference {
                    deleteDividerView.setVisibility(View.GONE);
                }
            }
        final boolean disabledByAdmin = isDisabledByAdmin();
            ImageView manageView = (ImageView) view.findViewById(R.id.manage_user);
            if (manageView != null) {
                if (mSettingsClickListener != null) {
@@ -116,10 +123,8 @@ public class UserPreference extends RestrictedPreference {
                    manageView.setVisibility(View.GONE);
                    manageDividerView.setVisibility(View.GONE);
                }
            manageView.setImageAlpha(disabledByAdmin ? ALPHA_DISABLED : ALPHA_ENABLED);
            }
        super.onBindViewHolder(view);
        dimIcon(disabledByAdmin);
        }
    }

    private int getSerialNumber() {