Add disabled by policy message as empty views in preferencefragment.
Change-Id: I296dc02c8e5cbea74f8415f4c8c5723f85e20b5b
This commit is contained in:
42
res/layout/admin_support_details_content.xml
Normal file
42
res/layout/admin_support_details_content.xml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!-- Layout used for displaying admin support details in empty preference fragments. -->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/admin_support_details"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="@*android:dimen/preference_fragment_padding_side"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
<TextView android:id="@+id/admin_support_msg"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
||||||
|
android:text="@string/default_admin_support_msg"
|
||||||
|
android:maxLength="200"
|
||||||
|
android:autoLink="email|phone"
|
||||||
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
|
<TextView android:id="@+id/admins_policies_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/admin_details_dialog_link_padding_top"
|
||||||
|
android:text="@string/admin_support_more_info"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
||||||
|
android:textColor="?android:attr/colorAccent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="?android:attr/selectableItemBackground" />
|
||||||
|
</LinearLayout>
|
@@ -73,6 +73,8 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<include layout="@layout/admin_support_details_content" />
|
||||||
|
|
||||||
<RelativeLayout android:id="@+id/button_bar"
|
<RelativeLayout android:id="@+id/button_bar"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -24,10 +25,18 @@ import android.content.IntentFilter;
|
|||||||
import android.content.RestrictionsManager;
|
import android.content.RestrictionsManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
|
||||||
|
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for settings screens that should be pin protected when in restricted mode.
|
* Base class for settings screens that should be pin protected when in restricted mode or
|
||||||
|
* that will display an admin support message in case an admin has disabled the options.
|
||||||
* The constructor for this class will take the restriction key that this screen should be
|
* The constructor for this class will take the restriction key that this screen should be
|
||||||
* locked by. If {@link RestrictionsManager.hasRestrictionsProvider()} and
|
* locked by. If {@link RestrictionsManager.hasRestrictionsProvider()} and
|
||||||
* {@link UserManager.hasUserRestriction()}, then the user will have to enter the restrictions
|
* {@link UserManager.hasUserRestriction()}, then the user will have to enter the restrictions
|
||||||
@@ -37,7 +46,8 @@ import android.os.UserManager;
|
|||||||
* {@link RestrictionsManager.hasRestrictionsProvider()} returns true, pass in
|
* {@link RestrictionsManager.hasRestrictionsProvider()} returns true, pass in
|
||||||
* {@link RESTRICT_IF_OVERRIDABLE} to the constructor instead of a restrictions key.
|
* {@link RESTRICT_IF_OVERRIDABLE} to the constructor instead of a restrictions key.
|
||||||
*/
|
*/
|
||||||
public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragment {
|
public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragment
|
||||||
|
implements View.OnClickListener {
|
||||||
|
|
||||||
protected static final String RESTRICT_IF_OVERRIDABLE = "restrict_if_overridable";
|
protected static final String RESTRICT_IF_OVERRIDABLE = "restrict_if_overridable";
|
||||||
|
|
||||||
@@ -55,6 +65,9 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
|
|||||||
private RestrictionsManager mRestrictionsManager;
|
private RestrictionsManager mRestrictionsManager;
|
||||||
|
|
||||||
private final String mRestrictionKey;
|
private final String mRestrictionKey;
|
||||||
|
private View mAdminSupportDetails;
|
||||||
|
private EnforcedAdmin mEnforcedAdmin;
|
||||||
|
private TextView mEmptyTextView;
|
||||||
|
|
||||||
// Receiver to clear pin status when the screen is turned off.
|
// Receiver to clear pin status when the screen is turned off.
|
||||||
private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
|
||||||
@@ -94,6 +107,13 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
|
|||||||
getActivity().registerReceiver(mScreenOffReceiver, offFilter);
|
getActivity().registerReceiver(mScreenOffReceiver, offFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
mAdminSupportDetails = initAdminSupportDetailsView();
|
||||||
|
mEmptyTextView = initEmptyTextView();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
@@ -178,6 +198,68 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
|
|||||||
return restricted && mRestrictionsManager.hasRestrictionsProvider();
|
return restricted && mRestrictionsManager.hasRestrictionsProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected View initAdminSupportDetailsView() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TextView initEmptyTextView() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAdminSupportDetailsView() {
|
||||||
|
mEnforcedAdmin = RestrictedLockUtils.checkIfRestrictionEnforced(getActivity(),
|
||||||
|
mRestrictionKey, UserHandle.myUserId());
|
||||||
|
if (mEnforcedAdmin != null) {
|
||||||
|
final Activity activity = getActivity();
|
||||||
|
DevicePolicyManager dpm = (DevicePolicyManager) activity.getSystemService(
|
||||||
|
Context.DEVICE_POLICY_SERVICE);
|
||||||
|
if (mEnforcedAdmin.userId == UserHandle.USER_NULL) {
|
||||||
|
mEnforcedAdmin.userId = UserHandle.myUserId();
|
||||||
|
}
|
||||||
|
CharSequence supportMessage = dpm.getShortSupportMessageForUser(
|
||||||
|
mEnforcedAdmin.component, mEnforcedAdmin.userId);
|
||||||
|
if (supportMessage != null) {
|
||||||
|
TextView textView = (TextView) activity.findViewById(R.id.admin_support_msg);
|
||||||
|
textView.setText(supportMessage);
|
||||||
|
}
|
||||||
|
activity.findViewById(R.id.admins_policies_list).setOnClickListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
if (view.getId() == R.id.admins_policies_list && mEnforcedAdmin != null) {
|
||||||
|
if (mEnforcedAdmin.component != null) {
|
||||||
|
intent.setClass(getActivity(), DeviceAdminAdd.class);
|
||||||
|
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mEnforcedAdmin.component);
|
||||||
|
// DeviceAdminAdd class may need to run as managed profile.
|
||||||
|
getActivity().startActivityAsUser(intent, UserHandle.of(mEnforcedAdmin.userId));
|
||||||
|
} else {
|
||||||
|
intent.setClass(getActivity(), Settings.DeviceAdminSettingsActivity.class);
|
||||||
|
// Activity merges both managed profile and parent users
|
||||||
|
// admins so show as same user as this activity.
|
||||||
|
getActivity().startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextView getEmptyTextView() {
|
||||||
|
return mEmptyTextView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDataSetChanged() {
|
||||||
|
highlightPreferenceIfNeeded();
|
||||||
|
if (mAdminSupportDetails != null && isUiRestricted()) {
|
||||||
|
updateAdminSupportDetailsView();
|
||||||
|
setEmptyView(mAdminSupportDetails);
|
||||||
|
} else if (mEmptyTextView != null) {
|
||||||
|
setEmptyView(mEmptyTextView);
|
||||||
|
}
|
||||||
|
super.onDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether restricted or actionable UI elements should be removed or disabled.
|
* Returns whether restricted or actionable UI elements should be removed or disabled.
|
||||||
*/
|
*/
|
||||||
|
@@ -176,13 +176,6 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
|||||||
unregisterObserverIfNeeded();
|
unregisterObserverIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
|
|
||||||
unregisterObserverIfNeeded();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showLoadingWhenEmpty() {
|
public void showLoadingWhenEmpty() {
|
||||||
View loading = getView().findViewById(R.id.loading_container);
|
View loading = getView().findViewById(R.id.loading_container);
|
||||||
setEmptyView(loading);
|
setEmptyView(loading);
|
||||||
@@ -220,7 +213,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDataSetChanged() {
|
protected void onDataSetChanged() {
|
||||||
highlightPreferenceIfNeeded();
|
highlightPreferenceIfNeeded();
|
||||||
updateEmptyView();
|
updateEmptyView();
|
||||||
}
|
}
|
||||||
@@ -290,6 +283,9 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setEmptyView(View v) {
|
public void setEmptyView(View v) {
|
||||||
|
if (mEmptyView != null) {
|
||||||
|
mEmptyView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
mEmptyView = v;
|
mEmptyView = v;
|
||||||
updateEmptyView();
|
updateEmptyView();
|
||||||
}
|
}
|
||||||
|
@@ -87,7 +87,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
private boolean mInitialScanStarted;
|
private boolean mInitialScanStarted;
|
||||||
private boolean mInitiateDiscoverable;
|
private boolean mInitiateDiscoverable;
|
||||||
|
|
||||||
private TextView mEmptyView;
|
|
||||||
private SwitchBar mSwitchBar;
|
private SwitchBar mSwitchBar;
|
||||||
|
|
||||||
private final IntentFilter mIntentFilter;
|
private final IntentFilter mIntentFilter;
|
||||||
@@ -136,10 +135,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
mInitialScanStarted = false;
|
mInitialScanStarted = false;
|
||||||
mInitiateDiscoverable = true;
|
mInitiateDiscoverable = true;
|
||||||
|
|
||||||
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
|
|
||||||
setEmptyView(mEmptyView);
|
|
||||||
mEmptyView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
|
||||||
|
|
||||||
final SettingsActivity activity = (SettingsActivity) getActivity();
|
final SettingsActivity activity = (SettingsActivity) getActivity();
|
||||||
mSwitchBar = activity.getSwitchBar();
|
mSwitchBar = activity.getSwitchBar();
|
||||||
|
|
||||||
@@ -175,7 +170,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
if (isUiRestricted()) {
|
if (isUiRestricted()) {
|
||||||
setDeviceListGroup(getPreferenceScreen());
|
setDeviceListGroup(getPreferenceScreen());
|
||||||
removeAllDevices();
|
removeAllDevices();
|
||||||
mEmptyView.setText(R.string.bluetooth_empty_list_user_restricted);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +292,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
mDevicePreferenceMap.clear();
|
mDevicePreferenceMap.clear();
|
||||||
|
|
||||||
if (isUiRestricted()) {
|
if (isUiRestricted()) {
|
||||||
messageId = R.string.bluetooth_empty_list_user_restricted;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +353,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
case BluetoothAdapter.STATE_OFF:
|
case BluetoothAdapter.STATE_OFF:
|
||||||
setOffMessage();
|
setOffMessage();
|
||||||
if (isUiRestricted()) {
|
if (isUiRestricted()) {
|
||||||
messageId = R.string.bluetooth_empty_list_user_restricted;
|
messageId = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -373,15 +366,28 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
setDeviceListGroup(preferenceScreen);
|
setDeviceListGroup(preferenceScreen);
|
||||||
removeAllDevices();
|
removeAllDevices();
|
||||||
if (messageId != 0) {
|
if (messageId != 0) {
|
||||||
mEmptyView.setText(messageId);
|
getEmptyTextView().setText(messageId);
|
||||||
}
|
}
|
||||||
if (!isUiRestricted()) {
|
if (!isUiRestricted()) {
|
||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TextView initEmptyTextView() {
|
||||||
|
TextView textView = (TextView) getView().findViewById(android.R.id.empty);
|
||||||
|
textView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||||
|
return textView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View initAdminSupportDetailsView() {
|
||||||
|
return getActivity().findViewById(R.id.admin_support_details);
|
||||||
|
}
|
||||||
|
|
||||||
private void setOffMessage() {
|
private void setOffMessage() {
|
||||||
if (mEmptyView == null) {
|
final TextView emptyView = getEmptyTextView();
|
||||||
|
if (emptyView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final CharSequence briefText = getText(R.string.bluetooth_empty_list_bluetooth_off);
|
final CharSequence briefText = getText(R.string.bluetooth_empty_list_bluetooth_off);
|
||||||
@@ -392,13 +398,13 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
|
|
||||||
if (!bleScanningMode) {
|
if (!bleScanningMode) {
|
||||||
// Show only the brief text if the scanning mode has been turned off.
|
// Show only the brief text if the scanning mode has been turned off.
|
||||||
mEmptyView.setText(briefText, TextView.BufferType.SPANNABLE);
|
emptyView.setText(briefText, TextView.BufferType.SPANNABLE);
|
||||||
} else {
|
} else {
|
||||||
final StringBuilder contentBuilder = new StringBuilder();
|
final StringBuilder contentBuilder = new StringBuilder();
|
||||||
contentBuilder.append(briefText);
|
contentBuilder.append(briefText);
|
||||||
contentBuilder.append("\n\n");
|
contentBuilder.append("\n\n");
|
||||||
contentBuilder.append(getText(R.string.ble_scan_notify_text));
|
contentBuilder.append(getText(R.string.ble_scan_notify_text));
|
||||||
LinkifyUtils.linkify(mEmptyView, contentBuilder, new LinkifyUtils.OnClickListener() {
|
LinkifyUtils.linkify(emptyView, contentBuilder, new LinkifyUtils.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
final SettingsActivity activity =
|
final SettingsActivity activity =
|
||||||
@@ -409,7 +415,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getPreferenceScreen().removeAll();
|
getPreferenceScreen().removeAll();
|
||||||
Spannable boldSpan = (Spannable) mEmptyView.getText();
|
Spannable boldSpan = (Spannable) emptyView.getText();
|
||||||
boldSpan.setSpan(
|
boldSpan.setSpan(
|
||||||
new TextAppearanceSpan(getActivity(), android.R.style.TextAppearance_Medium), 0,
|
new TextAppearanceSpan(getActivity(), android.R.style.TextAppearance_Medium), 0,
|
||||||
briefText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
briefText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
@@ -131,7 +131,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
private WifiDialog mDialog;
|
private WifiDialog mDialog;
|
||||||
private WriteWifiConfigToNfcDialog mWifiToNfcDialog;
|
private WriteWifiConfigToNfcDialog mWifiToNfcDialog;
|
||||||
|
|
||||||
private TextView mEmptyView;
|
|
||||||
private ProgressBar mProgressHeader;
|
private ProgressBar mProgressHeader;
|
||||||
|
|
||||||
// this boolean extra specifies whether to disable the Next button when not connected. Used by
|
// this boolean extra specifies whether to disable the Next button when not connected. Used by
|
||||||
@@ -280,7 +279,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mEmptyView = initEmptyView();
|
|
||||||
registerForContextMenu(getListView());
|
registerForContextMenu(getListView());
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
@@ -628,9 +626,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
public void onAccessPointsChanged() {
|
public void onAccessPointsChanged() {
|
||||||
// Safeguard from some delayed event handling
|
// Safeguard from some delayed event handling
|
||||||
if (getActivity() == null) return;
|
if (getActivity() == null) return;
|
||||||
|
|
||||||
if (isUiRestricted()) {
|
if (isUiRestricted()) {
|
||||||
addMessagePreference(R.string.wifi_empty_list_user_restricted);
|
getPreferenceScreen().removeAll();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int wifiState = mWifiManager.getWifiState();
|
final int wifiState = mWifiManager.getWifiState();
|
||||||
@@ -708,15 +705,26 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TextView initEmptyView() {
|
@Override
|
||||||
|
protected TextView initEmptyTextView() {
|
||||||
TextView emptyView = (TextView) getActivity().findViewById(android.R.id.empty);
|
TextView emptyView = (TextView) getActivity().findViewById(android.R.id.empty);
|
||||||
emptyView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
emptyView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||||
setEmptyView(emptyView);
|
|
||||||
return emptyView;
|
return emptyView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View initAdminSupportDetailsView() {
|
||||||
|
return getActivity().findViewById(R.id.admin_support_details);
|
||||||
|
}
|
||||||
|
|
||||||
private void setOffMessage() {
|
private void setOffMessage() {
|
||||||
if (mEmptyView == null) {
|
if (isUiRestricted()) {
|
||||||
|
getPreferenceScreen().removeAll();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView emptyTextView = getEmptyTextView();
|
||||||
|
if (emptyTextView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,17 +737,17 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
final boolean wifiScanningMode = Settings.Global.getInt(
|
final boolean wifiScanningMode = Settings.Global.getInt(
|
||||||
resolver, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1;
|
resolver, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1;
|
||||||
|
|
||||||
if (isUiRestricted() || !wifiScanningMode) {
|
if (!wifiScanningMode) {
|
||||||
// Show only the brief text if the user is not allowed to configure scanning settings,
|
// Show only the brief text if the user is not allowed to configure scanning settings,
|
||||||
// or the scanning mode has been turned off.
|
// or the scanning mode has been turned off.
|
||||||
mEmptyView.setText(briefText, BufferType.SPANNABLE);
|
emptyTextView.setText(briefText, BufferType.SPANNABLE);
|
||||||
} else {
|
} else {
|
||||||
// Append the description of scanning settings with link.
|
// Append the description of scanning settings with link.
|
||||||
final StringBuilder contentBuilder = new StringBuilder();
|
final StringBuilder contentBuilder = new StringBuilder();
|
||||||
contentBuilder.append(briefText);
|
contentBuilder.append(briefText);
|
||||||
contentBuilder.append("\n\n");
|
contentBuilder.append("\n\n");
|
||||||
contentBuilder.append(getText(R.string.wifi_scan_notify_text));
|
contentBuilder.append(getText(R.string.wifi_scan_notify_text));
|
||||||
LinkifyUtils.linkify(mEmptyView, contentBuilder, new LinkifyUtils.OnClickListener() {
|
LinkifyUtils.linkify(emptyTextView, contentBuilder, new LinkifyUtils.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
final SettingsActivity activity =
|
final SettingsActivity activity =
|
||||||
@@ -750,7 +758,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Embolden and enlarge the brief description anyway.
|
// Embolden and enlarge the brief description anyway.
|
||||||
Spannable boldSpan = (Spannable) mEmptyView.getText();
|
Spannable boldSpan = (Spannable) emptyTextView.getText();
|
||||||
boldSpan.setSpan(
|
boldSpan.setSpan(
|
||||||
new TextAppearanceSpan(getActivity(), android.R.style.TextAppearance_Medium), 0,
|
new TextAppearanceSpan(getActivity(), android.R.style.TextAppearance_Medium), 0,
|
||||||
briefText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
briefText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
@@ -758,7 +766,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addMessagePreference(int messageId) {
|
private void addMessagePreference(int messageId) {
|
||||||
if (mEmptyView != null) mEmptyView.setText(messageId);
|
TextView emptyTextView = getEmptyTextView();
|
||||||
|
if (emptyTextView != null) emptyTextView.setText(messageId);
|
||||||
getPreferenceScreen().removeAll();
|
getPreferenceScreen().removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -144,7 +144,7 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TextView initEmptyView() {
|
protected TextView initEmptyTextView() {
|
||||||
final LayoutInflater inflater = LayoutInflater.from(getActivity());
|
final LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||||
mEmptyFooter = (TextView) inflater.inflate(R.layout.setup_wifi_empty, getListView(), false);
|
mEmptyFooter = (TextView) inflater.inflate(R.layout.setup_wifi_empty, getListView(), false);
|
||||||
return mEmptyFooter;
|
return mEmptyFooter;
|
||||||
|
Reference in New Issue
Block a user