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

Commit afa3a1a0 authored by Jason Monk's avatar Jason Monk
Browse files

Fix ManagedServiceSettings to work with Preferencev14

Bug: 25007000
Change-Id: I5e3a59b77001ce0e2928b35fa1b87878e22d4fbd
parent 2b7592d8
Loading
Loading
Loading
Loading
+0 −44
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 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">

    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0px"
            android:layout_weight="1">

        <ListView android:id="@android:id/list"
                android:layout_width="match_parent" 
                android:layout_height="match_parent"
                android:paddingStart="@dimen/settings_side_margin"
                android:paddingEnd="@dimen/settings_side_margin"
                android:drawSelectorOnTop="false"
                android:fastScrollEnabled="true"
                android:scrollbarStyle="outsideInset" />

        <TextView android:id="@android:id/empty"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center"
                android:textAppearance="?android:attr/textAppearanceMedium" />

    </FrameLayout>

</LinearLayout>
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 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.notification;

import android.annotation.Nullable;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;

public abstract class EmptyTextSettings extends SettingsPreferenceFragment {

    private TextView mEmpty;

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mEmpty = new TextView(getContext());
        mEmpty.setGravity(Gravity.CENTER);
        TypedValue value = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, value, true);
        mEmpty.setTextAppearance(value.resourceId);
        ((ViewGroup) view.findViewById(R.id.list_container)).addView(mEmpty,
                new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        setEmptyView(mEmpty);
    }

    protected void setEmptyText(int text) {
        mEmpty.setText(text);
    }
}
+5 −13
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.notification;

import android.annotation.Nullable;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
@@ -30,19 +31,14 @@ import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.PreferenceScreen;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;

import java.util.Collections;
import java.util.List;

public abstract class ManagedServiceSettings extends SettingsPreferenceFragment {
public abstract class ManagedServiceSettings extends EmptyTextSettings {
    private final Config mConfig;

    private Context mContext;
@@ -73,13 +69,9 @@ public abstract class ManagedServiceSettings extends SettingsPreferenceFragment
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        final View v =  inflater.inflate(R.layout.managed_service_settings, container, false);
        mEmpty = (TextView) v.findViewById(android.R.id.empty);
        mEmpty.setText(mConfig.emptyText);
        ((ListView) v.findViewById(android.R.id.list)).setEmptyView(mEmpty);
        return v;
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setEmptyText(mConfig.emptyText);
    }

    @Override
+5 −14
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.notification;

import android.annotation.Nullable;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
@@ -38,27 +39,21 @@ import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.util.ArraySet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.internal.logging.MetricsLogger;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ZenAccessSettings extends SettingsPreferenceFragment {
public class ZenAccessSettings extends EmptyTextSettings {

    private final SettingObserver mObserver = new SettingObserver();

    private Context mContext;
    private PackageManager mPkgMan;
    private NotificationManager mNoMan;
    private TextView mEmpty;

    @Override
    protected int getMetricsCategory() {
@@ -76,12 +71,9 @@ public class ZenAccessSettings extends SettingsPreferenceFragment {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        final View v =  inflater.inflate(R.layout.managed_service_settings, container, false);
        mEmpty = (TextView) v.findViewById(android.R.id.empty);
        mEmpty.setText(R.string.zen_access_empty_text);
        return v;
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setEmptyText(R.string.zen_access_empty_text);
    }

    @Override
@@ -141,7 +133,6 @@ public class ZenAccessSettings extends SettingsPreferenceFragment {
            });
            screen.addPreference(pref);
        }
        mEmpty.setVisibility(apps.isEmpty() ? View.VISIBLE : View.GONE);
    }

    private boolean hasAccess(String pkg) {