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

Commit 923bc74c authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Part1: Show the restricted lock icon in place of the pref widget.

Add summary strings used for switch prefs if disabled by admin.

Bug: 25603665
Bug: 27263775
Change-Id: I88c2dd2e024f92da107bedc645641e285796d51f
parent 6cc1ba8e
Loading
Loading
Loading
Loading
+21 −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.
-->
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/restricted_icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_settings_lock_outline"
    android:gravity="end|center_vertical" />
 No newline at end of file
+31 −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.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/restricted_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_settings_lock_outline"
        android:gravity="end|center_vertical" />
    <!-- Based off frameworks/base/core/res/res/layout/preference_widget_switch.xml -->
    <Switch xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+android:id/switch_widget"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="false"
        android:clickable="false"
        android:background="@null" />
</merge>
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -773,6 +773,11 @@
    <!-- Summary for settings preference disabled by administrator [CHAR LIMIT=50] -->
    <string name="disabled_by_admin_summary_text">Controlled by admin</string>

    <!-- Summary for switch preference to denote it is switched on [CHAR LIMIT=50] -->
    <string name="enabled_by_admin">Enabled by administrator</string>
    <!-- Summary for switch preference to denote it is switched on [CHAR LIMIT=50] -->
    <string name="disabled_by_admin">Disabled by administrator</string>

    <!-- Option in navigation drawer that leads to Settings main screen [CHAR LIMIT=30] -->
    <string name="home">Home</string>

+6 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.view.View;

import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;

@@ -36,6 +37,7 @@ public class RestrictedPreference extends Preference {
    public RestrictedPreference(Context context, AttributeSet attrs,
            int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        setWidgetLayoutResource(R.layout.restricted_icon);
        mHelper = new RestrictedPreferenceHelper(context, this, attrs);
    }

@@ -56,6 +58,10 @@ public class RestrictedPreference extends Preference {
    public void onBindViewHolder(PreferenceViewHolder holder) {
        super.onBindViewHolder(holder);
        mHelper.onBindViewHolder(holder);
        final View restrictedIcon = holder.findViewById(R.id.restricted_icon);
        if (restrictedIcon != null) {
            restrictedIcon.setVisibility(isDisabledByAdmin() ? View.VISIBLE : View.GONE);
        }
    }

    @Override
+2 −6
Original line number Diff line number Diff line
@@ -91,13 +91,9 @@ public class RestrictedPreferenceHelper {
     * Modify PreferenceViewHolder to add padlock if restriction is disabled.
     */
    public void onBindViewHolder(PreferenceViewHolder holder) {
        final TextView titleView = (TextView) holder.findViewById(android.R.id.title);
        if (titleView != null) {
            RestrictedLockUtils.setTextViewPadlock(mContext, titleView, mDisabledByAdmin);
        if (mDisabledByAdmin) {
            holder.itemView.setEnabled(true);
        }
        }
        if (mUseAdminDisabledSummary) {
            final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
            if (summaryView != null) {
Loading