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

Commit 8a46f6c0 authored by Michael Bestas's avatar Michael Bestas Committed by Timi Rautamäki
Browse files

Settings: Wi-Fi picker UI changes for SUW

Change-Id: Ic8e97b78f19e59fe108c7c3304dfe7e7f49020a9
parent a7afd1ca
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -301,6 +301,17 @@
                android:value="true" />
        </activity>

        <activity
            android:name=".wifi.WifiSetupActivity"
            android:theme="@style/GlifV3Theme.Light">
            <intent-filter android:priority="1">
                <action android:name="android.net.wifi.SETUP_WIFI_NETWORK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                android:value="true" />
        </activity>

        <activity
            android:name="Settings$ConfigureWifiSettingsActivity"
            android:label="@string/wifi_configure_settings_preference_title"
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2021 The LineageOS 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">

    <path
        android:fillColor="?android:attr/colorPrimary"
        android:pathData="M12,3C7.79,3 3.7,4.41 0.38,7C4.41,12.06 7.89,16.37 12,21.5C16.08,16.42 20.24,11.24 23.65,7C20.32,4.41 16.22,3 12,3Z" />
</vector>
+3 −0
Original line number Diff line number Diff line
@@ -159,4 +159,7 @@
    <!-- FastCharge feature -->
    <string name="fast_charging_title">Fast charging</string>
    <string name="fast_charging_summary">Disable to reduce the heat produced by the device while charging or to extend the lifespan of the battery</string>

    <!-- Used in SetupWizard Wi-Fi network selection page [CHAR LIMIT=60] -->
    <string name="wifi_setup_wizard_title">Select Wi\u2011Fi network</string>
</resources>
+52 −8
Original line number Diff line number Diff line
@@ -46,9 +46,11 @@ import android.util.FeatureFlagUtils;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.VisibleForTesting;
@@ -81,6 +83,9 @@ import com.android.wifitrackerlib.WifiEntry;
import com.android.wifitrackerlib.WifiEntry.ConnectCallback;
import com.android.wifitrackerlib.WifiPickerTracker;

import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.GlifPreferenceLayout;

import java.time.Clock;
import java.time.ZoneOffset;
import java.util.List;
@@ -147,6 +152,8 @@ public class WifiSettings2 extends RestrictedSettingsFragment
    // Enable the Next button when a Wi-Fi network is connected.
    private boolean mEnableNextOnConnection;

    private boolean mIsInSetupWizard;

    // This string extra specifies a network to open the connect dialog on, so the user can enter
    // network credentials.  This is used by quick settings for secured networks, among other
    // things.
@@ -215,8 +222,20 @@ public class WifiSettings2 extends RestrictedSettingsFragment
        super.onViewCreated(view, savedInstanceState);
        final Activity activity = getActivity();
        if (activity != null) {
            if (mIsInSetupWizard) {
                mProgressHeader = null;

                GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
                layout.setDividerInsets(Integer.MAX_VALUE, 0);

                layout.setIcon(getContext().getDrawable(R.drawable.ic_wifi_setup));
                layout.setHeaderText(R.string.wifi_setup_wizard_title);

                return;
            } else {
                mProgressHeader = setPinnedHeaderView(R.layout.progress_header)
                        .findViewById(R.id.progress_bar_animation);
            }
            setProgressBarVisible(false);
        }
        ((SettingsActivity) activity).getSwitchBar().setSwitchBarText(
@@ -235,6 +254,20 @@ public class WifiSettings2 extends RestrictedSettingsFragment
        addPreferences();

        mIsRestricted = isUiRestricted();

        final Intent intent = this.getIntent();
        mIsInSetupWizard = WizardManagerHelper.isAnySetupWizard(intent);
    }

    @Override
    public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
            Bundle savedInstanceState) {
        if (mIsInSetupWizard) {
            GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
            return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
        } else {
            return super.onCreateRecyclerView(inflater, parent, savedInstanceState);
        }
    }

    private void addPreferences() {
@@ -318,8 +351,13 @@ public class WifiSettings2 extends RestrictedSettingsFragment
                }
            }
        };
        if (mIsInSetupWizard) {
            mConfigureWifiSettingsPreference.setVisible(false);
            mDataUsagePreference.setVisible(false);
        } else {
            registerForContextMenu(getListView());
            setHasOptionsMenu(true);
        }

        if (savedInstanceState != null) {
            mDialogMode = savedInstanceState.getInt(SAVE_DIALOG_MODE);
@@ -368,10 +406,14 @@ public class WifiSettings2 extends RestrictedSettingsFragment
     * @return new WifiEnabler
     */
    private WifiEnabler createWifiEnabler() {
        if (mIsInSetupWizard) {
            return null;
        } else {
            final SettingsActivity activity = (SettingsActivity) getActivity();
            return new WifiEnabler(activity, new SwitchBarController(activity.getSwitchBar()),
                    mMetricsFeatureProvider);
        }
    }

    @Override
    public void onResume() {
@@ -746,9 +788,11 @@ public class WifiSettings2 extends RestrictedSettingsFragment

                if (mClickedConnect) {
                    mClickedConnect = false;
                    if (!mIsInSetupWizard) {
                        scrollToPreference(mConnectedWifiEntryPreferenceCategory);
                    }
                }
            }
        } else {
            mConnectedWifiEntryPreferenceCategory.removeAll();
        }
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 * Copyright (C) 2021 The LineageOS 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 android.content.res.Resources;

import androidx.preference.PreferenceFragmentCompat;

import com.android.settings.ButtonBarHandler;
import com.android.settings.SetupWizardUtils;

public class WifiSetupActivity extends WifiPickerActivity implements ButtonBarHandler {

    @Override
    protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
        resid = SetupWizardUtils.getTheme(getIntent());
        super.onApplyThemeResource(theme, resid, first);
    }

}