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

Commit 98b216dc authored by Bartosz Fabianowski's avatar Bartosz Fabianowski Committed by android-build-merger
Browse files

Hide "Changes made by your organization's admin" when empty

am: 49349545

Change-Id: Ided6278456fe5ffdbb843717a1ec7070e7a3d3dc
parents 42d97f86 49349545
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@
                    android:selectable="false"/>
    </PreferenceCategory>

    <PreferenceCategory android:title="@string/enterprise_privacy_exposure_changes_category">
    <PreferenceCategory android:title="@string/enterprise_privacy_exposure_changes_category"
                        android:key="exposure_changes_category">
        <Preference android:fragment="com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages"
                    android:key="number_enterprise_installed_packages"
                    android:title="@string/enterprise_privacy_enterprise_installed_packages"/>
+15 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public abstract class DynamicAvailabilityPreferenceController extends Preference

    private Preference mPreference;
    private PreferenceScreen mScreen;
    private PreferenceAvailabilityObserver mAvailabilityObserver = null;

    public DynamicAvailabilityPreferenceController(Context context, Lifecycle lifecycle) {
        super(context);
@@ -37,6 +38,14 @@ public abstract class DynamicAvailabilityPreferenceController extends Preference
        }
    }

    public void setAvailabilityObserver(PreferenceAvailabilityObserver observer) {
        mAvailabilityObserver = observer;
    }

    public PreferenceAvailabilityObserver getAvailabilityObserver() {
        return mAvailabilityObserver;
    }

    @Override
    public void displayPreference(PreferenceScreen screen) {
        mScreen = screen;
@@ -56,4 +65,10 @@ public abstract class DynamicAvailabilityPreferenceController extends Preference
            mScreen.addPreference(mPreference);
        }
    }

    protected void notifyOnAvailabilityUpdate(boolean available) {
        if (mAvailabilityObserver != null) {
            mAvailabilityObserver.onPreferenceAvailabilityUpdated(getPreferenceKey(), available);
        }
    }
}
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.
 */

package com.android.settings.core;

/**
 * @deprecated This interface allows a {@link android.support.v7.preference.PreferenceGroup}'s
 * controller to observe the availability of the {@link android.support.v7.preference.Preference}s
 * inside it, hiding the group when all preferences become unavailable. In the future,
 * {@link android.support.v7.preference.PreferenceGroup} will have native support for that
 * functionality, removing the need for this interface.
 */
public interface PreferenceAvailabilityObserver {

    /**
     * Notifies the observer that the availability of the preference identified by {@code key} has
     * been updated.
     */
    void onPreferenceAvailabilityUpdated(String key, boolean available);
}
+3 −2
Original line number Diff line number Diff line
@@ -50,15 +50,15 @@ public abstract class AdminGrantedPermissionsPreferenceControllerBase
                true /* async */,
                (num) -> {
                    if (num == 0) {
                        preference.setVisible(false);
                        mHasApps = false;
                    } else {
                        preference.setVisible(true);
                        preference.setSummary(mContext.getResources().getQuantityString(
                                R.plurals.enterprise_privacy_number_packages_lower_bound,
                                num, num));
                        mHasApps = true;
                    }
                    preference.setVisible(mHasApps);
                    notifyOnAvailabilityUpdate(mHasApps);
                });
    }

@@ -80,6 +80,7 @@ public abstract class AdminGrantedPermissionsPreferenceControllerBase
        mFeatureProvider.calculateNumberOfAppsWithAdminGrantedPermissions(mPermissions,
                false /* async */, (num) -> haveAppsWithAdminGrantedPermissions[0] = num > 0);
        mHasApps = haveAppsWithAdminGrantedPermissions[0];
        notifyOnAvailabilityUpdate(mHasApps);
        return mHasApps;
    }

+3 −1
Original line number Diff line number Diff line
@@ -42,7 +42,9 @@ public class AlwaysOnVpnCurrentUserPreferenceController

    @Override
    public boolean isAvailable() {
        return mFeatureProvider.isAlwaysOnVpnSetInCurrentUser();
        final boolean available = mFeatureProvider.isAlwaysOnVpnSetInCurrentUser();
        notifyOnAvailabilityUpdate(available);
        return available;
    }

    @Override
Loading