Upload basic UI files for Wi-Fi DPP Settings development II.
Add 3 fragments: WifiDppQrCodeGeneratorFragment WifiDppChooseSavedWifiNetworkFragment WifiDppAddDeviceFragment Bug: 118797380 118797202 118794978 118796825 118794858 Test: atest WifiDppConfiguratorActivityTest atest WifiDppQrCodeScannerFragmentTest atest atest RunSettingsRoboTests Change-Id: I2fbc2f46f941d49b63e4ac74d92f94bf617d2b9b
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.wifi.dpp;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* After getting Wi-Fi network information and(or) QR code, this fragment config a device to connect
|
||||
* to the Wi-Fi network.
|
||||
*/
|
||||
public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.wifi_dpp_add_device_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated (Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.wifi.dpp;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* After a camera APP scanned a Wi-Fi DPP QR code, it can trigger
|
||||
* {@code WifiDppConfiguratorActivity} to start with this fragment to choose a saved Wi-Fi network.
|
||||
*/
|
||||
public class WifiDppChooseSavedWifiNetworkFragment extends WifiDppQrCodeBaseFragment {
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.wifi_dpp_choose_saved_wifi_network_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated (Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
}
|
||||
}
|
@@ -67,25 +67,48 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.wifi_dpp_activity);
|
||||
|
||||
// Hide action bar
|
||||
ActionBar action = getActionBar();
|
||||
if (action != null) {
|
||||
action.hide();
|
||||
}
|
||||
|
||||
mFragmentManager = getSupportFragmentManager();
|
||||
mFragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
|
||||
final int launchMode = getIntent().getIntExtra(EXTRA_LAUNCH_MODE,
|
||||
LaunchMode.LAUNCH_MODE_NOT_DEFINED.getMode());
|
||||
if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode()) {
|
||||
WifiDppQrCodeScannerFragment scanFragment = new WifiDppQrCodeScannerFragment();
|
||||
mFragmentTransaction.add(R.id.fragment_container, scanFragment);
|
||||
mFragmentTransaction.commit();
|
||||
addQrCodeScannerFragment();
|
||||
} else if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_GENERATOR.getMode()) {
|
||||
addQrCodeGeneratorFragment();
|
||||
} else if (launchMode == LaunchMode.LAUNCH_MODE_CHOOSE_SAVED_WIFI_NETWORK.getMode()) {
|
||||
addChooseSavedWifiNetworkFragment();
|
||||
} else {
|
||||
Log.e(TAG, "Launch with an invalid mode extra");
|
||||
setResult(Activity.RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void addQrCodeScannerFragment() {
|
||||
WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment();
|
||||
mFragmentTransaction.add(R.id.fragment_container, fragment);
|
||||
mFragmentTransaction.addToBackStack(null);
|
||||
mFragmentTransaction.commit();
|
||||
}
|
||||
|
||||
private void addQrCodeGeneratorFragment() {
|
||||
WifiDppQrCodeGeneratorFragment fragment = new WifiDppQrCodeGeneratorFragment();
|
||||
mFragmentTransaction.add(R.id.fragment_container, fragment);
|
||||
mFragmentTransaction.addToBackStack(null);
|
||||
mFragmentTransaction.commit();
|
||||
}
|
||||
|
||||
private void addChooseSavedWifiNetworkFragment() {
|
||||
ActionBar action = getActionBar();
|
||||
if (action != null) {
|
||||
action.hide();
|
||||
}
|
||||
|
||||
WifiDppChooseSavedWifiNetworkFragment fragment =
|
||||
new WifiDppChooseSavedWifiNetworkFragment();
|
||||
mFragmentTransaction.add(R.id.fragment_container, fragment);
|
||||
mFragmentTransaction.addToBackStack(null);
|
||||
mFragmentTransaction.commit();
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,9 @@ import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
@@ -29,13 +32,37 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.core.InstrumentedFragment;
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* There are below 4 fragments for Wi-Fi DPP UI flow, to reduce redundant code of UI components,
|
||||
* this parent fragment instantiates all UI components and provides setting APIs for them.
|
||||
*
|
||||
* {@code WifiDppQrCodeScannerFragment}
|
||||
* {@code WifiDppQrCodeGeneratorFragment}
|
||||
* {@code WifiDppChooseSavedWifiNetworkFragment}
|
||||
* {@code WifiDppAddDeviceFragment}
|
||||
*/
|
||||
public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
|
||||
private TextView mTitle;
|
||||
private TextView mDescription;
|
||||
private SurfaceView mPreviewView;
|
||||
private TextView mErrorMessage; //optional, view used to surface connectivity errors to the user
|
||||
private Button mButtonLeft;
|
||||
private Button mButtonRight;
|
||||
|
||||
private SurfaceView mPreviewView; //optional, for WifiDppQrCodeScannerFragment
|
||||
private ImageView mDecorateViiew; //optional, for WifiDppQrCodeScannerFragment
|
||||
private TextView mErrorMessage; //optional, for WifiDppQrCodeScannerFragment
|
||||
|
||||
private ImageView mBarcodeView; //optional, for WifiDppQrCodeGeneratorFragment
|
||||
|
||||
private ListView mSavedWifiNetworkList; //optional, for WifiDppChooseSavedWifiNetworkFragment
|
||||
|
||||
private ProgressBar mProgressBar; //optional, for WifiDppAddDeviceFragment
|
||||
private ImageView mWifiApPictureView; //optional, for WifiDppAddDeviceFragment
|
||||
private TextView mChooseDifferentNetwork;//optional, for WifiDppAddDeviceFragment
|
||||
|
||||
private Button mButtonLeft; //optional, for WifiDppQrCodeScannerFragment,
|
||||
// WifiDppChooseSavedWifiNetworkFragment,
|
||||
// WifiDppAddDeviceFragment
|
||||
private Button mButtonRight; //optional, for WifiDppQrCodeScannerFragment,
|
||||
// WifiDppChooseSavedWifiNetworkFragment,
|
||||
// WifiDppAddDeviceFragment
|
||||
|
||||
abstract protected int getLayout();
|
||||
|
||||
@@ -61,8 +88,19 @@ public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
|
||||
private void initView(View view) {
|
||||
mTitle = view.findViewById(R.id.title);
|
||||
mDescription = view.findViewById(R.id.description);
|
||||
|
||||
mPreviewView = view.findViewById(R.id.preview_view);
|
||||
mDecorateViiew = view.findViewById(R.id.decorate_view);
|
||||
mErrorMessage = view.findViewById(R.id.error_message);
|
||||
|
||||
mBarcodeView = view.findViewById(R.id.barcode_view);
|
||||
|
||||
mSavedWifiNetworkList = view.findViewById(R.id.saved_wifi_network_list);
|
||||
|
||||
mProgressBar = view.findViewById(R.id.progress_bar);
|
||||
mWifiApPictureView = view.findViewById(R.id.wifi_ap_picture_view);
|
||||
mChooseDifferentNetwork = view.findViewById(R.id.choose_different_network);
|
||||
|
||||
mButtonLeft = view.findViewById(R.id.button_left);
|
||||
mButtonRight = view.findViewById(R.id.button_right);
|
||||
}
|
||||
@@ -75,33 +113,76 @@ public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
|
||||
mDescription.setText(description);
|
||||
}
|
||||
|
||||
/** optional, for WifiDppQrCodeScannerFragment */
|
||||
protected void setErrorMessage(String errorMessage) {
|
||||
if (mErrorMessage != null) {
|
||||
mErrorMessage.setText(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* optional, for WifiDppQrCodeScannerFragment,
|
||||
* WifiDppChooseSavedWifiNetworkFragment,
|
||||
* WifiDppAddDeviceFragment
|
||||
*/
|
||||
protected void setLeftButtonText(String text) {
|
||||
mButtonLeft.setText(text);
|
||||
if (mButtonLeft != null) {
|
||||
mButtonLeft.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* optional, for WifiDppQrCodeScannerFragment,
|
||||
* WifiDppChooseSavedWifiNetworkFragment,
|
||||
* WifiDppAddDeviceFragment
|
||||
*/
|
||||
protected void setRightButtonText(String text) {
|
||||
mButtonRight.setText(text);
|
||||
if (mButtonRight != null) {
|
||||
mButtonRight.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* optional, for WifiDppQrCodeScannerFragment,
|
||||
* WifiDppChooseSavedWifiNetworkFragment,
|
||||
* WifiDppAddDeviceFragment
|
||||
*/
|
||||
protected void hideLeftButton() {
|
||||
mButtonLeft.setVisibility(View.INVISIBLE);
|
||||
if (mButtonLeft != null) {
|
||||
mButtonLeft.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* optional, for WifiDppQrCodeScannerFragment,
|
||||
* WifiDppChooseSavedWifiNetworkFragment,
|
||||
* WifiDppAddDeviceFragment
|
||||
*/
|
||||
protected void hideRightButton() {
|
||||
mButtonRight.setVisibility(View.INVISIBLE);
|
||||
if (mButtonRight != null) {
|
||||
mButtonRight.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* optional, for WifiDppQrCodeScannerFragment,
|
||||
* WifiDppChooseSavedWifiNetworkFragment,
|
||||
* WifiDppAddDeviceFragment
|
||||
*/
|
||||
protected void setLeftButtonOnClickListener(View.OnClickListener listener) {
|
||||
mButtonLeft.setOnClickListener(listener);
|
||||
if (mButtonLeft != null) {
|
||||
mButtonLeft.setOnClickListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* optional, for WifiDppQrCodeScannerFragment,
|
||||
* WifiDppChooseSavedWifiNetworkFragment,
|
||||
* WifiDppAddDeviceFragment
|
||||
*/
|
||||
protected void setRightButtonOnClickListener(View.OnClickListener listener) {
|
||||
mButtonRight.setOnClickListener(listener);
|
||||
if (mButtonRight != null) {
|
||||
mButtonRight.setOnClickListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.wifi.dpp;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* After sharing a saved Wi-Fi network, {@code WifiDppConfiguratorActivity} start with this fragment
|
||||
* to generate a Wi-Fi DPP QR code for other device to initiate as an enrollee.
|
||||
*/
|
||||
public class WifiDppQrCodeGeneratorFragment extends WifiDppQrCodeBaseFragment {
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.wifi_dpp_qrcode_generator_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated (Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
}
|
||||
}
|
@@ -19,10 +19,7 @@ package com.android.settings.wifi.dpp;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import com.android.settings.R;
|
||||
|
||||
public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment {
|
||||
|
Reference in New Issue
Block a user