Settings: Network setup UI changes for SUW

Co-authored-by: Dhina17 <dhinalogu@gmail.com>
Co-authored-by: Erfan Abdi <erfangplus@gmail.com>
Co-authored-by: Michael Bestas <mkbestas@lineageos.org>
Change-Id: Ic8e97b78f19e59fe108c7c3304dfe7e7f49020a9
This commit is contained in:
Michael Bestas
2021-08-24 01:18:55 +03:00
parent d25dbfa776
commit 13093942c1
4 changed files with 162 additions and 6 deletions

View File

@@ -516,6 +516,17 @@
android:value="true" />
</activity>
<activity
android:name=".network.NetworkSetupActivity"
android:exported="true">
<intent-filter android:priority="1">
<action android:name="android.settings.NETWORK_PROVIDER_SETUP" />
<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=".wifi.WifiPickerActivity"
android:permission="android.permission.CHANGE_WIFI_STATE"

View File

@@ -0,0 +1,26 @@
<?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,2A8,8 0 0,0 4,10C4,14.03 7,17.42 11,17.93V19H10A1,1 0 0,0 9,20H2V22H9A1,1 0 0,0 10,23H14A1,1 0 0,0 15,22H22V20H15A1,1 0 0,0 14,19H13V17.93C17,17.43 20,14.03 20,10A8,8 0 0,0 12,2M12,4C12,4 12.74,5.28 13.26,7H10.74C11.26,5.28 12,4 12,4M9.77,4.43C9.5,4.93 9.09,5.84 8.74,7H6.81C7.5,5.84 8.5,4.93 9.77,4.43M14.23,4.44C15.5,4.94 16.5,5.84 17.19,7H15.26C14.91,5.84 14.5,4.93 14.23,4.44M6.09,9H8.32C8.28,9.33 8.25,9.66 8.25,10C8.25,10.34 8.28,10.67 8.32,11H6.09C6.03,10.67 6,10.34 6,10C6,9.66 6.03,9.33 6.09,9M10.32,9H13.68C13.72,9.33 13.75,9.66 13.75,10C13.75,10.34 13.72,10.67 13.68,11H10.32C10.28,10.67 10.25,10.34 10.25,10C10.25,9.66 10.28,9.33 10.32,9M15.68,9H17.91C17.97,9.33 18,9.66 18,10C18,10.34 17.97,10.67 17.91,11H15.68C15.72,10.67 15.75,10.34 15.75,10C15.75,9.66 15.72,9.33 15.68,9M6.81,13H8.74C9.09,14.16 9.5,15.07 9.77,15.56C8.5,15.06 7.5,14.16 6.81,13M10.74,13H13.26C12.74,14.72 12,16 12,16C12,16 11.26,14.72 10.74,13M15.26,13H17.19C16.5,14.16 15.5,15.07 14.23,15.57C14.5,15.07 14.91,14.16 15.26,13Z" />
</vector>

View File

@@ -29,6 +29,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.location.LocationManager;
import android.net.EthernetManager;
import android.net.NetworkTemplate;
@@ -46,10 +47,12 @@ import android.util.EventLog;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -65,6 +68,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.AirplaneModeEnabler;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilitySetupWizardUtils;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.datausage.DataUsagePreference;
@@ -104,6 +108,10 @@ import com.android.wifitrackerlib.WifiEntry;
import com.android.wifitrackerlib.WifiEntry.ConnectCallback;
import com.android.wifitrackerlib.WifiPickerTracker;
import com.google.android.setupcompat.template.FooterButtonStyleUtils;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.GlifPreferenceLayout;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
@@ -178,6 +186,8 @@ public class NetworkProviderSettings extends RestrictedDashboardFragment
// 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.
@@ -290,6 +300,18 @@ public class NetworkProviderSettings extends RestrictedDashboardFragment
return;
}
if (mIsInSetupWizard) {
GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
final Drawable icon = getContext().getDrawable(R.drawable.ic_network_setup);
final String title = getContext().getString(R.string.provider_internet_settings);
AccessibilitySetupWizardUtils.updateGlifPreferenceLayout(getContext(), layout,
title, "" /* description */, icon);
FooterButtonStyleUtils.applyPrimaryButtonPartnerResource(activity, getNextButton(),
true);
return;
}
setPinnedHeaderView(com.android.settingslib.widget.progressbar.R.layout.progress_header);
setProgressBarVisible(false);
@@ -366,6 +388,8 @@ public class NetworkProviderSettings extends RestrictedDashboardFragment
fixConnectivityItem.setVisible(!mIsGuest && (!isAirplaneModeOn || isWifiEnabled));
}
};
final Intent intent = this.getIntent();
mIsInSetupWizard = WizardManagerHelper.isAnySetupWizard(intent);
}
private void updateUserType() {
@@ -380,6 +404,17 @@ public class NetworkProviderSettings extends RestrictedDashboardFragment
return TAG;
}
@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);
}
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.network_provider_settings;
@@ -518,6 +553,11 @@ public class NetworkProviderSettings extends RestrictedDashboardFragment
}
};
if (mIsInSetupWizard) {
mConfigureWifiSettingsPreference.setVisible(false);
mDataUsagePreference.setVisible(false);
}
if (savedInstanceState != null) {
mDialogMode = savedInstanceState.getInt(SAVE_DIALOG_MODE);
mDialogWifiEntryKey = savedInstanceState.getString(SAVE_DIALOG_WIFIENTRY_KEY);
@@ -1057,7 +1097,9 @@ public class NetworkProviderSettings extends RestrictedDashboardFragment
if (mClickedConnect) {
mClickedConnect = false;
scrollToPreference(connectedWifiPreferenceCategory);
if (!mIsInSetupWizard) {
scrollToPreference(connectedWifiPreferenceCategory);
}
}
}
} else {
@@ -1221,10 +1263,12 @@ public class NetworkProviderSettings extends RestrictedDashboardFragment
@VisibleForTesting
void setAdditionalSettingsSummaries() {
mConfigureWifiSettingsPreference.setSummary(getString(
isWifiWakeupEnabled()
? R.string.wifi_configure_settings_preference_summary_wakeup_on
: R.string.wifi_configure_settings_preference_summary_wakeup_off));
if (!mIsInSetupWizard) {
mConfigureWifiSettingsPreference.setSummary(getString(
isWifiWakeupEnabled()
? R.string.wifi_configure_settings_preference_summary_wakeup_on
: R.string.wifi_configure_settings_preference_summary_wakeup_off));
}
final int numSavedNetworks = mWifiPickerTracker == null ? 0 :
mWifiPickerTracker.getNumSavedNetworks();
@@ -1272,7 +1316,9 @@ public class NetworkProviderSettings extends RestrictedDashboardFragment
}
protected void setProgressBarVisible(boolean visible) {
showPinnedHeader(visible);
if (!mIsInSetupWizard) {
showPinnedHeader(visible);
}
}
@VisibleForTesting

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2012 The Android Open Source Project
* Copyright (C) 2021-2024 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.network;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
import com.android.settings.ButtonBarHandler;
import com.android.settings.network.NetworkProviderSettings;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SetupWizardUtils;
import com.android.settings.wifi.p2p.WifiP2pSettings;
import com.android.settings.wifi.savedaccesspoints2.SavedAccessPointsWifiSettings2;
import com.google.android.setupdesign.util.ThemeHelper;
public class NetworkSetupActivity extends SettingsActivity implements ButtonBarHandler {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
setTheme(R.style.SettingsPreferenceTheme_SetupWizard);
ThemeHelper.trySetDynamicColor(this);
findViewById(R.id.content_parent).setFitsSystemWindows(false);
}
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
if (!modIntent.hasExtra(EXTRA_SHOW_FRAGMENT)) {
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, getNetworkProviderSettingsClass().getName());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID,
R.string.provider_internet_settings);
}
return modIntent;
}
@Override
protected boolean isValidFragment(String fragmentName) {
final boolean isSavedAccessPointsWifiSettings =
SavedAccessPointsWifiSettings2.class.getName().equals(fragmentName);
if (NetworkProviderSettings.class.getName().equals(fragmentName)
|| WifiP2pSettings.class.getName().equals(fragmentName)
|| isSavedAccessPointsWifiSettings) {
return true;
}
return false;
}
/* package */ Class<? extends PreferenceFragmentCompat> getNetworkProviderSettingsClass() {
return NetworkProviderSettings.class;
}
}