Fix ManagedServiceSettings to work with Preferencev14
Bug: 25007000 Change-Id: I5e3a59b77001ce0e2928b35fa1b87878e22d4fbd
This commit is contained in:
@@ -1,44 +0,0 @@
|
|||||||
<?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
src/com/android/settings/notification/EmptyTextSettings.java
Normal file
50
src/com/android/settings/notification/EmptyTextSettings.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.DialogFragment;
|
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;
|
||||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class ManagedServiceSettings extends SettingsPreferenceFragment {
|
public abstract class ManagedServiceSettings extends EmptyTextSettings {
|
||||||
private final Config mConfig;
|
private final Config mConfig;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -73,13 +69,9 @@ public abstract class ManagedServiceSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
Bundle savedInstanceState) {
|
super.onViewCreated(view, savedInstanceState);
|
||||||
final View v = inflater.inflate(R.layout.managed_service_settings, container, false);
|
setEmptyText(mConfig.emptyText);
|
||||||
mEmpty = (TextView) v.findViewById(android.R.id.empty);
|
|
||||||
mEmpty.setText(mConfig.emptyText);
|
|
||||||
((ListView) v.findViewById(android.R.id.list)).setEmptyView(mEmpty);
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
@@ -38,27 +39,21 @@ import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
|||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ZenAccessSettings extends SettingsPreferenceFragment {
|
public class ZenAccessSettings extends EmptyTextSettings {
|
||||||
|
|
||||||
private final SettingObserver mObserver = new SettingObserver();
|
private final SettingObserver mObserver = new SettingObserver();
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private PackageManager mPkgMan;
|
private PackageManager mPkgMan;
|
||||||
private NotificationManager mNoMan;
|
private NotificationManager mNoMan;
|
||||||
private TextView mEmpty;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMetricsCategory() {
|
protected int getMetricsCategory() {
|
||||||
@@ -76,12 +71,9 @@ public class ZenAccessSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
Bundle savedInstanceState) {
|
super.onViewCreated(view, savedInstanceState);
|
||||||
final View v = inflater.inflate(R.layout.managed_service_settings, container, false);
|
setEmptyText(R.string.zen_access_empty_text);
|
||||||
mEmpty = (TextView) v.findViewById(android.R.id.empty);
|
|
||||||
mEmpty.setText(R.string.zen_access_empty_text);
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -141,7 +133,6 @@ public class ZenAccessSettings extends SettingsPreferenceFragment {
|
|||||||
});
|
});
|
||||||
screen.addPreference(pref);
|
screen.addPreference(pref);
|
||||||
}
|
}
|
||||||
mEmpty.setVisibility(apps.isEmpty() ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasAccess(String pkg) {
|
private boolean hasAccess(String pkg) {
|
||||||
|
Reference in New Issue
Block a user