Merge "[WifiSetup] Show MAC address in footer" into mnc-dev
This commit is contained in:
38
res/layout/setup_wifi_mac_address.xml
Normal file
38
res/layout/setup_wifi_mac_address.xml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/setup_add_network_item_height"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="@dimen/setup_list_no_icon_padding"
|
||||||
|
android:text="@string/wifi_advanced_mac_address_title" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/mac_address"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="@dimen/setup_list_no_icon_padding" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@@ -19,6 +19,7 @@ package com.android.settings.wifi;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@@ -46,6 +47,7 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
private SetupWizardListLayout mLayout;
|
private SetupWizardListLayout mLayout;
|
||||||
private View mAddOtherNetworkItem;
|
private View mAddOtherNetworkItem;
|
||||||
private TextView mEmptyFooter;
|
private TextView mEmptyFooter;
|
||||||
|
private View mMacAddressFooter;
|
||||||
private boolean mListLastEmpty = false;
|
private boolean mListLastEmpty = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,6 +68,9 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mMacAddressFooter = inflater.inflate(R.layout.setup_wifi_mac_address, list, false);
|
||||||
|
list.addFooterView(mMacAddressFooter, null, false);
|
||||||
|
|
||||||
final NavigationBar navigationBar = mLayout.getNavigationBar();
|
final NavigationBar navigationBar = mLayout.getNavigationBar();
|
||||||
if (navigationBar != null) {
|
if (navigationBar != null) {
|
||||||
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
|
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
|
||||||
@@ -82,6 +87,8 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
if (hasNextButton()) {
|
if (hasNextButton()) {
|
||||||
getNextButton().setVisibility(View.GONE);
|
getNextButton().setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateMacAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,6 +97,12 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
updateFooter(getPreferenceScreen().getPreferenceCount() == 0);
|
updateFooter(getPreferenceScreen().getPreferenceCount() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWifiStateChanged(int state) {
|
||||||
|
super.onWifiStateChanged(state);
|
||||||
|
updateMacAddress();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerForContextMenu(View view) {
|
public void registerForContextMenu(View view) {
|
||||||
// Suppressed during setup wizard
|
// Suppressed during setup wizard
|
||||||
@@ -137,12 +150,14 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
protected void updateFooter(boolean isEmpty) {
|
protected void updateFooter(boolean isEmpty) {
|
||||||
if (isEmpty != mListLastEmpty) {
|
if (isEmpty != mListLastEmpty) {
|
||||||
final ListView list = getListView();
|
final ListView list = getListView();
|
||||||
if (isEmpty) {
|
list.removeFooterView(mEmptyFooter);
|
||||||
list.removeFooterView(mAddOtherNetworkItem);
|
list.removeFooterView(mAddOtherNetworkItem);
|
||||||
|
list.removeFooterView(mMacAddressFooter);
|
||||||
|
if (isEmpty) {
|
||||||
list.addFooterView(mEmptyFooter, null, false);
|
list.addFooterView(mEmptyFooter, null, false);
|
||||||
} else {
|
} else {
|
||||||
list.removeFooterView(mEmptyFooter);
|
|
||||||
list.addFooterView(mAddOtherNetworkItem, null, true);
|
list.addFooterView(mAddOtherNetworkItem, null, true);
|
||||||
|
list.addFooterView(mMacAddressFooter, null, false);
|
||||||
}
|
}
|
||||||
mListLastEmpty = isEmpty;
|
mListLastEmpty = isEmpty;
|
||||||
}
|
}
|
||||||
@@ -169,4 +184,20 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateMacAddress() {
|
||||||
|
if (mMacAddressFooter != null) {
|
||||||
|
String macAddress = null;
|
||||||
|
if (mWifiManager != null) {
|
||||||
|
android.net.wifi.WifiInfo connectionInfo = mWifiManager.getConnectionInfo();
|
||||||
|
if (connectionInfo != null) {
|
||||||
|
macAddress = connectionInfo.getMacAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final TextView macAddressTextView =
|
||||||
|
(TextView) mMacAddressFooter.findViewById(R.id.mac_address);
|
||||||
|
macAddressTextView.setText(!TextUtils.isEmpty(macAddress) ?
|
||||||
|
macAddress : getString(R.string.status_unavailable));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user