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

Commit 8a337681 authored by c_pengz's avatar c_pengz Committed by Linux Build Service Account
Browse files

Settings: Wifi ap settings feature

    Show the connected devices as a list

Conflicts:
	src/com/android/settings/TetherSettings.java
	src/com/android/settings/wifi/WifiApEnabler.java

Change-Id: I993d8e5e87011d1223eef0b9430b7880d7777d51
parent 8a23c93f
Loading
Loading
Loading
Loading
+76 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
   Copyright (c) 2015, The Linux Foundation. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?android:attr/activatedBackgroundIndicator"
    android:gravity="center_vertical"
    android:minHeight="48dp"
    android:paddingEnd="?android:attr/scrollbarSize" >

    <RelativeLayout
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_marginStart="15dip"
        android:layout_marginEnd="6dip"
        android:layout_marginTop="6dip"
        android:layout_marginBottom="6dip"
        android:layout_weight="1">

        <TextView android:id="@+id/subtitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:text="@string/wifi_tether_checkbox_text"
            android:textAppearance="?android:attr/textAppearanceListItem"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal" />

        <TextView android:id="@+id/subsummary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/subtitle"
            android:layout_alignStart="@+id/subtitle"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="?android:attr/textColorSecondary"
            android:maxLines="4" />

    </RelativeLayout>

    <Switch
        android:id="@+id/switchWidget"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:clickable="true"
        android:focusable="false"
        android:padding="8dip" />

</LinearLayout>
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -65,4 +65,10 @@

    <!-- Whether to enable roaming settings -->
    <bool name="config_roamingsettings_enabled">false</bool>

    <!-- Whether to show hotspot settings -->
    <bool name="show_wifi_hotspot_settings">false</bool>

    <!-- Whether to hide wifi hotspot -->
    <bool name="hide_wifi_hotspot">false</bool>
</resources>

res/xml/tether_prefs.xml

100644 → 100755
+6 −0
Original line number Diff line number Diff line
@@ -25,6 +25,12 @@
        android:key="enable_wifi_ap"
        android:title="@string/wifi_tether_checkbox_text" />

    <com.android.settings.HotspotPreference
        android:key="enable_wifi_ap_ext"
        android:title="@string/wifi_tether_checkbox_text"
        android:layout="@layout/hotspot_checkbox"
        android:persistent="false" />

    <Preference
        android:key="wifi_ap_ssid_and_security"
        android:title="@string/wifi_tether_configure_ap_text"
+98 −0
Original line number Diff line number Diff line
/*
   Copyright (c) 2015, The Linux Foundation. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


package com.android.settings;

import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Switch;
import android.widget.TextView;

public class HotspotPreference extends Preference implements OnCheckedChangeListener {

    private Switch mSwitch;
    private TextView mSubSummary;
    private Context mContext;
    private boolean mSwitchEnabled;

    public HotspotPreference(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext = context;
    }

    public HotspotPreference(Context context, AttributeSet attrs) {
        this(context, attrs, com.android.internal.R.attr.switchPreferenceStyle);
        mContext = context;
    }

    public HotspotPreference(Context context) {
        this(context, null);
        mContext = context;
    }

    @Override
    public void onBindViewHolder(PreferenceViewHolder view) {
        super.onBindViewHolder(view);
        mSubSummary = (TextView) view.findViewById(R.id.subsummary);
        mSubSummary.setVisibility(View.GONE);
        mSwitch = (Switch) view.findViewById(R.id.switchWidget);
        mSwitch.setOnCheckedChangeListener(this);
        setChecked(mSwitchEnabled);
    }


    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        callChangeListener(isChecked);
    }

    public void setSummary(CharSequence summary) {
        if (mSubSummary == null) {
            return;
        }
        mSubSummary.setVisibility(summary != null ? View.VISIBLE : View.GONE);
        mSubSummary.setText(summary);
    }

    public void setChecked(boolean state) {
        if (mSwitch != null) {
            mSwitch.setOnCheckedChangeListener(null);
            mSwitch.setChecked(state);
            mSwitch.setOnCheckedChangeListener(this);
        }
        mSwitchEnabled=state;
    }
}
+30 −8
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class TetherSettings extends RestrictedSettingsFragment

    private static final String USB_TETHER_SETTINGS = "usb_tether_settings";
    private static final String ENABLE_WIFI_AP = "enable_wifi_ap";
    private static final String ENABLE_WIFI_AP_EXT = "enable_wifi_ap_ext";
    private static final String ENABLE_BLUETOOTH_TETHERING = "enable_bluetooth_tethering";
    private static final String TETHER_CHOICE = "TETHER_TYPE";
    private static final String DATA_SAVER_FOOTER = "disabled_on_data_saver";
@@ -74,7 +75,7 @@ public class TetherSettings extends RestrictedSettingsFragment
    private SwitchPreference mUsbTether;

    private WifiApEnabler mWifiApEnabler;
    private SwitchPreference mEnableWifiAp;
    private Preference mEnableWifiAp;

    private SwitchPreference mBluetoothTether;

@@ -151,9 +152,29 @@ public class TetherSettings extends RestrictedSettingsFragment
                    BluetoothProfile.PAN);
        }

        mCreateNetwork = findPreference(WIFI_AP_SSID_AND_SECURITY);

        boolean enableWifiApSettingsExt = getResources().getBoolean(R.bool.show_wifi_hotspot_settings);
        boolean isWifiApEnabled = getResources().getBoolean(R.bool.hide_wifi_hotspot);
        if (enableWifiApSettingsExt) {
            mEnableWifiAp =
                    (HotspotPreference) findPreference(ENABLE_WIFI_AP_EXT);
            getPreferenceScreen().removePreference(findPreference(ENABLE_WIFI_AP));
            getPreferenceScreen().removePreference(mCreateNetwork);
            Intent intent = new Intent();
            intent.setAction("com.qti.ap.settings");
            intent.setPackage("com.qti.extsettings");
            mEnableWifiAp.setIntent(intent);
        } else {
            mEnableWifiAp =
                    (SwitchPreference) findPreference(ENABLE_WIFI_AP);
        Preference wifiApSettings = findPreference(WIFI_AP_SSID_AND_SECURITY);
            getPreferenceScreen().removePreference(findPreference(ENABLE_WIFI_AP_EXT));
        }
        if (isWifiApEnabled) {
            getPreferenceScreen().removePreference(mEnableWifiAp);
            getPreferenceScreen().removePreference(mCreateNetwork);
        }

        mUsbTether = (SwitchPreference) findPreference(USB_TETHER_SETTINGS);
        mBluetoothTether = (SwitchPreference) findPreference(ENABLE_BLUETOOTH_TETHERING);

@@ -179,7 +200,7 @@ public class TetherSettings extends RestrictedSettingsFragment
            initWifiTethering();
        } else {
            getPreferenceScreen().removePreference(mEnableWifiAp);
            getPreferenceScreen().removePreference(wifiApSettings);
            getPreferenceScreen().removePreference(mCreateNetwork);
        }

        if (!bluetoothAvailable) {
@@ -223,11 +244,12 @@ public class TetherSettings extends RestrictedSettingsFragment
        final Activity activity = getActivity();
        mWifiConfig = mWifiManager.getWifiApConfiguration();
        mSecurityType = getResources().getStringArray(R.array.wifi_ap_security);

        mCreateNetwork = findPreference(WIFI_AP_SSID_AND_SECURITY);

        mRestartWifiApAfterConfigChange = false;

        if (mCreateNetwork == null) {
            return;
        }

        if (mWifiConfig == null) {
            final String s = activity.getString(
                    com.android.internal.R.string.wifi_tether_configure_ssid_default);
Loading