Remove wifi scan-always dialog.
When wifi is switched off we no longer want a notification dialog about scan-always, instead using in-panel text. bug:8907190 Change-Id: I707f306a056068d92f69070873f1e6330b598b1e
This commit is contained in:
@@ -1202,15 +1202,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".wifi.WifiNotifyScanModeActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:theme="@style/Transparent">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.wifi.action.NOTIFY_SCAN_ALWAYS_AVAILABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".bluetooth.RequestPermissionHelperActivity"
|
||||
android:label="@string/bluetooth_pairing_request"
|
||||
android:excludeFromRecents="true"
|
||||
|
@@ -40,7 +40,6 @@ public class WifiEnabler implements CompoundButton.OnCheckedChangeListener {
|
||||
private final Context mContext;
|
||||
private Switch mSwitch;
|
||||
private AtomicBoolean mConnected = new AtomicBoolean(false);
|
||||
private AtomicBoolean mNotifyScanMode = new AtomicBoolean(true);
|
||||
|
||||
private final WifiManager mWifiManager;
|
||||
private boolean mStateMachineEvent;
|
||||
@@ -75,7 +74,6 @@ public class WifiEnabler implements CompoundButton.OnCheckedChangeListener {
|
||||
// The order matters! We really should not depend on this. :(
|
||||
mIntentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
|
||||
mIntentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
registerForNotifyUserOnScanModeChange();
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
@@ -102,29 +100,6 @@ public class WifiEnabler implements CompoundButton.OnCheckedChangeListener {
|
||||
mSwitch.setEnabled(isEnabled || isDisabled);
|
||||
}
|
||||
|
||||
private void getPersistedNotifyScanMode() {
|
||||
mNotifyScanMode.set(Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.WIFI_NOTIFY_SCAN_ALWAYS_AVAILABLE, 1) == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Observes settings changes to notify the user when scan mode is active and
|
||||
* Wi-Fi is turned off
|
||||
*/
|
||||
private void registerForNotifyUserOnScanModeChange() {
|
||||
ContentObserver contentObserver = new ContentObserver(null) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
getPersistedNotifyScanMode();
|
||||
}
|
||||
};
|
||||
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.Global.getUriFor(Settings.Global.WIFI_NOTIFY_SCAN_ALWAYS_AVAILABLE),
|
||||
false, contentObserver);
|
||||
getPersistedNotifyScanMode();
|
||||
}
|
||||
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
//Do nothing if called as a result of a state machine event
|
||||
if (mStateMachineEvent) {
|
||||
@@ -144,13 +119,6 @@ public class WifiEnabler implements CompoundButton.OnCheckedChangeListener {
|
||||
mWifiManager.setWifiApEnabled(null, false);
|
||||
}
|
||||
|
||||
if (isChecked == false) {
|
||||
if (mWifiManager.isScanAlwaysAvailable() && mNotifyScanMode.get()) {
|
||||
Intent intent = new Intent(WifiManager.ACTION_NOTIFY_SCAN_ALWAYS_AVAILABLE);
|
||||
mContext.startActivityAsUser(intent, null, UserHandle.CURRENT);
|
||||
}
|
||||
}
|
||||
|
||||
if (mWifiManager.setWifiEnabled(isChecked)) {
|
||||
// Intent has been taken into account, disable until new state is active
|
||||
mSwitch.setEnabled(false);
|
||||
|
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.wifi;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.location.LocationManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
/**
|
||||
* This activity notifies the user that wifi scans are still available when Wi-Fi is being
|
||||
* turned off
|
||||
*/
|
||||
public class WifiNotifyScanModeActivity extends Activity {
|
||||
private DialogFragment mDialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Intent intent = getIntent();
|
||||
if (intent != null && intent.getAction()
|
||||
.equals(WifiManager.ACTION_NOTIFY_SCAN_ALWAYS_AVAILABLE)) {
|
||||
createDialog();
|
||||
} else {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void createDialog() {
|
||||
if (mDialog == null) {
|
||||
mDialog = AlertDialogFragment.newInstance();
|
||||
mDialog.show(getFragmentManager(), "dialog");
|
||||
}
|
||||
}
|
||||
|
||||
private void dismissDialog() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
mDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
dismissDialog();
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
createDialog();
|
||||
}
|
||||
|
||||
void doPositiveButton(boolean checked) {
|
||||
Settings.Global.putInt(getContentResolver(),
|
||||
Settings.Global.WIFI_NOTIFY_SCAN_ALWAYS_AVAILABLE, checked ? 0 : 1);
|
||||
finish();
|
||||
}
|
||||
|
||||
public static class AlertDialogFragment extends DialogFragment {
|
||||
static AlertDialogFragment newInstance() {
|
||||
AlertDialogFragment frag = new AlertDialogFragment();
|
||||
return frag;
|
||||
}
|
||||
|
||||
public AlertDialogFragment() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
View checkBoxView = View.inflate(getActivity(), R.layout.wifi_notify_scan_mode, null);
|
||||
final CheckBox checkBox = (CheckBox) checkBoxView.findViewById(R.id.checkbox);
|
||||
final String msg;
|
||||
if (Settings.Secure.isLocationProviderEnabled(getActivity().getContentResolver(),
|
||||
LocationManager.NETWORK_PROVIDER)) {
|
||||
msg = getString(R.string.wifi_scan_notify_text_location_on);
|
||||
} else {
|
||||
msg = getString(R.string.wifi_scan_notify_text_location_off);
|
||||
}
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setMessage(msg)
|
||||
.setView(checkBoxView)
|
||||
.setPositiveButton(R.string.dlg_ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
((WifiNotifyScanModeActivity) getActivity()).doPositiveButton(
|
||||
checkBox.isChecked());
|
||||
}
|
||||
}
|
||||
)
|
||||
.setNegativeButton(R.string.dlg_cancel,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
((WifiNotifyScanModeActivity) getActivity()).finish();
|
||||
}
|
||||
}
|
||||
)
|
||||
.create();
|
||||
}
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
((WifiNotifyScanModeActivity) getActivity()).finish();
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,6 +30,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.location.LocationManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.NetworkInfo.DetailedState;
|
||||
@@ -46,6 +47,7 @@ import android.os.UserManager;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@@ -743,11 +745,28 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
break;
|
||||
|
||||
case WifiManager.WIFI_STATE_DISABLED:
|
||||
addMessagePreference(R.string.wifi_empty_list_wifi_off);
|
||||
setOffMessage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setOffMessage() {
|
||||
if (mEmptyView != null) {
|
||||
mEmptyView.setText(R.string.wifi_empty_list_wifi_off);
|
||||
mEmptyView.append("\n\n");
|
||||
int resId;
|
||||
if (Settings.Secure.isLocationProviderEnabled(getActivity().getContentResolver(),
|
||||
LocationManager.NETWORK_PROVIDER)) {
|
||||
resId = R.string.wifi_scan_notify_text_location_on;
|
||||
} else {
|
||||
resId = R.string.wifi_scan_notify_text_location_off;
|
||||
}
|
||||
CharSequence charSeq = getText(resId);
|
||||
mEmptyView.append(charSeq);
|
||||
}
|
||||
getPreferenceScreen().removeAll();
|
||||
}
|
||||
|
||||
private void addMessagePreference(int messageId) {
|
||||
if (mEmptyView != null) mEmptyView.setText(messageId);
|
||||
getPreferenceScreen().removeAll();
|
||||
@@ -906,7 +925,7 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
break;
|
||||
|
||||
case WifiManager.WIFI_STATE_DISABLED:
|
||||
addMessagePreference(R.string.wifi_empty_list_wifi_off);
|
||||
setOffMessage();
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user