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

Commit b3e77e2f authored by Arne Coucheron's avatar Arne Coucheron
Browse files

Revert "Add switch button in Settings for Wi-Fi Call."

This reverts commit 8fc9246c.

Change-Id: I568bfaaa564eeadf62e40d5bec4b7c1f497ae3b3
parent fc4d6b7e
Loading
Loading
Loading
Loading

res/layout/wfc_checkbox.xml

deleted100644 → 0
+0 −77
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016, 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_calling_settings_title"
            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
+8 −5
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved.-->

<!-- Copyright (C) 2008 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,12 +29,17 @@
        settings:keywords="@string/keywords_wifi_calling"
        android:fragment="com.android.settings.WifiCallingSettings" />

    <com.android.settings.WFCPreference
    <PreferenceScreen
        android:key="wifi_calling_enhanced_settings"
        android:title="@string/wifi_calling_settings_title"
        android:summaryOff="@null"
        android:summaryOn="@null"
        android:persistent="false"
        android:layout="@layout/wfc_checkbox" />
        android:persistent="false">
        <intent
            android:action="android.intent.action.MAIN"
            android:targetPackage="com.qualcomm.qti.wfcservice"
            android:targetClass="com.qualcomm.qti.wfcservice.WifiCallingEnhancedSettings" />
    </PreferenceScreen>

    <com.android.settingslib.RestrictedPreference
        android:fragment="com.android.settings.TetherSettings"
+0 −98
Original line number Diff line number Diff line
/*
Copyright (c) 2016, 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.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 WFCPreference extends Preference implements OnCheckedChangeListener {

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

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

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

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

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

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        callChangeListener(isChecked);
        mSwitchEnabled = isChecked;
    }

    public void setSummary(CharSequence summary) {
        if (mSubSummary == null) {
            remainSummary = summary;
            return;
        }
        mSubSummary.setText(summary);
    }

    public void setChecked(boolean state) {
        if (mSwitch != null) {
            mSwitch.setOnCheckedChangeListener(null);
            mSwitch.setChecked(state);
            mSwitch.setOnCheckedChangeListener(this);
        }
        mSwitchEnabled=state;
    }
}
+17 −82
Original line number Diff line number Diff line
/* Copyright (c) 2016, The Linux Foundation. All rights reserved.*/

/*
 * Copyright (C) 2009 The Android Open Source Project
 *
@@ -88,9 +86,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
    private static final String KEY_WFC_SETTINGS = "wifi_calling_settings";
    private static final String KEY_WFC_ENHANCED_SETTINGS = "wifi_calling_enhanced_settings";

    private static final String ACTION_WIFI_CALL_ON = "com.android.wificall.TURNON";
    private static final String ACTION_WIFI_CALL_OFF = "com.android.wificall.TURNOFF";
    private static final String WIFI_CALLING_PREFERRED = "preference";
    private static final String KEY_NETWORK_RESET = "network_reset";
    private static final String KEY_NFC_CATEGORY_SETTINGS = "nfc_category_settings";
    private static final String KEY_NFC_PAYMENT_SETTINGS = "nfc_payment_settings";
@@ -116,7 +111,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
    private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
    private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";

    private Preference mButtonWfc;
    private PreferenceScreen mButtonWfc;
    private boolean mEnhancedWFCSettingsEnabled = false;

    private IWFCService mWFCService;
@@ -139,25 +134,15 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
    };

    private IWFCServiceCB mCallback = new IWFCServiceCB.Stub() {
        public void updateWFCMessage(String errorCode) {
            if (!mEnhancedWFCSettingsEnabled || (errorCode == null)) {
        public void updateWFCMessage(String s) {
            if (!mEnhancedWFCSettingsEnabled || (s == null)) {
                if(DEBUG) Log.e(TAG, "updateWFCMessage fail.");
                return ;
            }
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    if(DEBUG) Log.d (TAG, "new UI thread.");
                    try {
                        if (mWFCService.getWifiCallingStatus()) {
                            if (mButtonWfc instanceof WFCPreference) {
                                ((WFCPreference) mButtonWfc).setSummary(errorCode);
                            } else {
                                mButtonWfc.setSummary(errorCode);
                            }
                        }
                    } catch (RemoteException r) {
                        Log.e(TAG, "getWifiCallingStatus RemoteException");
                    }
                    mButtonWfc.setSummary(s);
                }
            });

@@ -341,14 +326,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
        return MetricsEvent.WIRELESS;
    }

    private void broadcastWifiCallingStatus(Context ctx, boolean isTurnOn, int preference) {
        if(DEBUG) Log.d(TAG, "broadcastWifiCallingStatus:");
        Intent intent = new Intent(isTurnOn ? ACTION_WIFI_CALL_ON
                    : ACTION_WIFI_CALL_OFF);
        intent.putExtra(WIFI_CALLING_PREFERRED, preference);
        ctx.sendBroadcast(intent);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -383,52 +360,21 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
        mEnhancedWFCSettingsEnabled = getActivity().getResources().getBoolean(
                    R.bool.wifi_call_enhanced_setting);
        if (mEnhancedWFCSettingsEnabled) {
            mButtonWfc = (WFCPreference) findPreference(KEY_WFC_ENHANCED_SETTINGS);
            mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_ENHANCED_SETTINGS);
            removePreference(KEY_WFC_SETTINGS);
            mButtonWfc.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
                public boolean onPreferenceClick(Preference preference) {
                    Intent intent = new Intent();
                    intent.setAction("android.intent.action.MAIN");
                    intent.setPackage("com.qualcomm.qti.wfcservice");
                    intent.setClassName("com.qualcomm.qti.wfcservice",
                            "com.qualcomm.qti.wfcservice.WifiCallingEnhancedSettings");
                    mButtonWfc.setIntent(intent);
                    return false;
                }
            });

            mButtonWfc.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object value) {
                    int wfcPreference = -1;
                    try {
                        wfcPreference = mWFCService.getWifiCallingPreference();
                    } catch (RemoteException re) {
                        Log.e(TAG, "getWifiCallingPreference RemoteException");
                        return false;
                    }

                    boolean isChecked = (Boolean) value;

                    try {
                        mWFCService.setWifiCalling(isChecked, wfcPreference);
                    } catch (RemoteException r) {
                        Log.e(TAG, "setWifiCalling RemoteException");
                    }

                    if (!isChecked) {
                        ((WFCPreference) preference).setSummary(R.string.disabled);
                    }

                    broadcastWifiCallingStatus(getActivity(), isChecked, wfcPreference);
                    return false;
                }
            });
        } else {
            mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_SETTINGS);
            removePreference(KEY_WFC_ENHANCED_SETTINGS);
        }

        if (mEnhancedWFCSettingsEnabled) {
            //bind WFC service
            final Intent intentWfc = new Intent();
            intentWfc.setAction("com.qualcomm.qti.wfcservice.IWFCService");
            intentWfc.setPackage("com.qualcomm.qti.wfcservice");
            activity.bindService(intentWfc, mConnection, Context.BIND_AUTO_CREATE);
        }

        String toggleable = Settings.Global.getString(activity.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);

@@ -578,14 +524,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
    public void onResume() {
        super.onResume();

        if (mEnhancedWFCSettingsEnabled && mWFCService == null) {
            //bind WFC service
            final Intent intentWfc = new Intent();
            intentWfc.setAction("com.qualcomm.qti.wfcservice.IWFCService");
            intentWfc.setPackage("com.qualcomm.qti.wfcservice");
            getActivity().bindService(intentWfc, mConnection, Context.BIND_AUTO_CREATE);
        }

        mAirplaneModeEnabler.resume();
        if (mNfcEnabler != null) {
            mNfcEnabler.resume();
@@ -602,12 +540,9 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
                        context, ImsManager.getWfcMode(context)));
            } else {
                if (!ImsManager.isWfcEnabledByUser(context)) {
                    ((WFCPreference) mButtonWfc).setChecked(false);
                    ((WFCPreference) mButtonWfc).setSummary(R.string.disabled);
                    mButtonWfc.setSummary(R.string.disabled);
                } else {
                    ((WFCPreference) mButtonWfc).setChecked(true);
                    ((WFCPreference) mButtonWfc).setSummary(
                            SystemProperties.get("sys.wificall.status.msg"));
                    mButtonWfc.setSummary(SystemProperties.get("sys.wificall.status.msg"));
                }
            }

+0 −3
Original line number Diff line number Diff line
@@ -35,8 +35,5 @@ import org.codeaurora.wfcservice.IWFCServiceCB;
interface IWFCService {
    void registerCallback(IWFCServiceCB cb);
    void unregisterCallback(IWFCServiceCB cb);
    void setWifiCalling(boolean state, int preference);
    boolean getWifiCallingStatus();
    int getWifiCallingPreference();
}