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:
48
res/layout/wifi_dpp_add_device_fragment.xml
Normal file
48
res/layout/wifi_dpp_add_device_fragment.xml
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/root"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/wifi_dpp_fragment_header"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="true"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/wifi_ap_picture_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/choose_different_network"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
<include layout="@layout/wifi_dpp_fragment_footer"
|
||||||
|
android:gravity="center|bottom"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
35
res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
Normal file
35
res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/root"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/wifi_dpp_fragment_header"/>
|
||||||
|
|
||||||
|
<ListView android:id="@+id/saved_wifi_network_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<include layout="@layout/wifi_dpp_fragment_footer"
|
||||||
|
android:gravity="center|bottom"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
34
res/layout/wifi_dpp_qrcode_generator_fragment.xml
Normal file
34
res/layout/wifi_dpp_qrcode_generator_fragment.xml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/root"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/wifi_dpp_fragment_header"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/barcode_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/root"
|
android:id="@+id/root"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@@ -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);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.wifi_dpp_activity);
|
setContentView(R.layout.wifi_dpp_activity);
|
||||||
|
|
||||||
// Hide action bar
|
|
||||||
ActionBar action = getActionBar();
|
|
||||||
if (action != null) {
|
|
||||||
action.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
mFragmentManager = getSupportFragmentManager();
|
mFragmentManager = getSupportFragmentManager();
|
||||||
mFragmentTransaction = getSupportFragmentManager().beginTransaction();
|
mFragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
||||||
final int launchMode = getIntent().getIntExtra(EXTRA_LAUNCH_MODE,
|
final int launchMode = getIntent().getIntExtra(EXTRA_LAUNCH_MODE,
|
||||||
LaunchMode.LAUNCH_MODE_NOT_DEFINED.getMode());
|
LaunchMode.LAUNCH_MODE_NOT_DEFINED.getMode());
|
||||||
if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode()) {
|
if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode()) {
|
||||||
WifiDppQrCodeScannerFragment scanFragment = new WifiDppQrCodeScannerFragment();
|
addQrCodeScannerFragment();
|
||||||
mFragmentTransaction.add(R.id.fragment_container, scanFragment);
|
} else if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_GENERATOR.getMode()) {
|
||||||
mFragmentTransaction.commit();
|
addQrCodeGeneratorFragment();
|
||||||
|
} else if (launchMode == LaunchMode.LAUNCH_MODE_CHOOSE_SAVED_WIFI_NETWORK.getMode()) {
|
||||||
|
addChooseSavedWifiNetworkFragment();
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Launch with an invalid mode extra");
|
Log.e(TAG, "Launch with an invalid mode extra");
|
||||||
setResult(Activity.RESULT_CANCELED);
|
setResult(Activity.RESULT_CANCELED);
|
||||||
finish();
|
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.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
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.core.InstrumentedFragment;
|
||||||
import com.android.settings.R;
|
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 {
|
public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
|
||||||
private TextView mTitle;
|
private TextView mTitle;
|
||||||
private TextView mDescription;
|
private TextView mDescription;
|
||||||
private SurfaceView mPreviewView;
|
|
||||||
private TextView mErrorMessage; //optional, view used to surface connectivity errors to the user
|
private SurfaceView mPreviewView; //optional, for WifiDppQrCodeScannerFragment
|
||||||
private Button mButtonLeft;
|
private ImageView mDecorateViiew; //optional, for WifiDppQrCodeScannerFragment
|
||||||
private Button mButtonRight;
|
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();
|
abstract protected int getLayout();
|
||||||
|
|
||||||
@@ -61,8 +88,19 @@ public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
|
|||||||
private void initView(View view) {
|
private void initView(View view) {
|
||||||
mTitle = view.findViewById(R.id.title);
|
mTitle = view.findViewById(R.id.title);
|
||||||
mDescription = view.findViewById(R.id.description);
|
mDescription = view.findViewById(R.id.description);
|
||||||
|
|
||||||
mPreviewView = view.findViewById(R.id.preview_view);
|
mPreviewView = view.findViewById(R.id.preview_view);
|
||||||
|
mDecorateViiew = view.findViewById(R.id.decorate_view);
|
||||||
mErrorMessage = view.findViewById(R.id.error_message);
|
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);
|
mButtonLeft = view.findViewById(R.id.button_left);
|
||||||
mButtonRight = view.findViewById(R.id.button_right);
|
mButtonRight = view.findViewById(R.id.button_right);
|
||||||
}
|
}
|
||||||
@@ -75,33 +113,76 @@ public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
|
|||||||
mDescription.setText(description);
|
mDescription.setText(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** optional, for WifiDppQrCodeScannerFragment */
|
||||||
protected void setErrorMessage(String errorMessage) {
|
protected void setErrorMessage(String errorMessage) {
|
||||||
if (mErrorMessage != null) {
|
if (mErrorMessage != null) {
|
||||||
mErrorMessage.setText(errorMessage);
|
mErrorMessage.setText(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* optional, for WifiDppQrCodeScannerFragment,
|
||||||
|
* WifiDppChooseSavedWifiNetworkFragment,
|
||||||
|
* WifiDppAddDeviceFragment
|
||||||
|
*/
|
||||||
protected void setLeftButtonText(String text) {
|
protected void setLeftButtonText(String text) {
|
||||||
|
if (mButtonLeft != null) {
|
||||||
mButtonLeft.setText(text);
|
mButtonLeft.setText(text);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* optional, for WifiDppQrCodeScannerFragment,
|
||||||
|
* WifiDppChooseSavedWifiNetworkFragment,
|
||||||
|
* WifiDppAddDeviceFragment
|
||||||
|
*/
|
||||||
protected void setRightButtonText(String text) {
|
protected void setRightButtonText(String text) {
|
||||||
|
if (mButtonRight != null) {
|
||||||
mButtonRight.setText(text);
|
mButtonRight.setText(text);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* optional, for WifiDppQrCodeScannerFragment,
|
||||||
|
* WifiDppChooseSavedWifiNetworkFragment,
|
||||||
|
* WifiDppAddDeviceFragment
|
||||||
|
*/
|
||||||
protected void hideLeftButton() {
|
protected void hideLeftButton() {
|
||||||
|
if (mButtonLeft != null) {
|
||||||
mButtonLeft.setVisibility(View.INVISIBLE);
|
mButtonLeft.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* optional, for WifiDppQrCodeScannerFragment,
|
||||||
|
* WifiDppChooseSavedWifiNetworkFragment,
|
||||||
|
* WifiDppAddDeviceFragment
|
||||||
|
*/
|
||||||
protected void hideRightButton() {
|
protected void hideRightButton() {
|
||||||
|
if (mButtonRight != null) {
|
||||||
mButtonRight.setVisibility(View.INVISIBLE);
|
mButtonRight.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* optional, for WifiDppQrCodeScannerFragment,
|
||||||
|
* WifiDppChooseSavedWifiNetworkFragment,
|
||||||
|
* WifiDppAddDeviceFragment
|
||||||
|
*/
|
||||||
protected void setLeftButtonOnClickListener(View.OnClickListener listener) {
|
protected void setLeftButtonOnClickListener(View.OnClickListener listener) {
|
||||||
|
if (mButtonLeft != null) {
|
||||||
mButtonLeft.setOnClickListener(listener);
|
mButtonLeft.setOnClickListener(listener);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* optional, for WifiDppQrCodeScannerFragment,
|
||||||
|
* WifiDppChooseSavedWifiNetworkFragment,
|
||||||
|
* WifiDppAddDeviceFragment
|
||||||
|
*/
|
||||||
protected void setRightButtonOnClickListener(View.OnClickListener listener) {
|
protected void setRightButtonOnClickListener(View.OnClickListener listener) {
|
||||||
|
if (mButtonRight != null) {
|
||||||
mButtonRight.setOnClickListener(listener);
|
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.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment {
|
public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment {
|
||||||
|
@@ -35,18 +35,38 @@ public class WifiDppConfiguratorActivityTest {
|
|||||||
new ActivityTestRule<>(WifiDppConfiguratorActivity.class);
|
new ActivityTestRule<>(WifiDppConfiguratorActivity.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLaunchModeQrCodeScanner_shouldNotAutoFinish() {
|
public void launchActivity_modeQrCodeScanner_shouldNotAutoFinish() {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
||||||
WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode());
|
WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode());
|
||||||
mActivityRule.launchActivity(intent);
|
mActivityRule.launchActivity(intent);
|
||||||
|
|
||||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||||
mActivityRule.finishActivity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoLaunchMode_shouldFinishActivityWithResultCodeCanceled() {
|
public void launchActivity_modeQrCodeGenerator_shouldNotAutoFinish() {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
||||||
|
WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_GENERATOR.getMode());
|
||||||
|
mActivityRule.launchActivity(intent);
|
||||||
|
|
||||||
|
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchActivity_modeChooseSavedWifiNetwork_shouldNotAutoFinish() {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
||||||
|
WifiDppConfiguratorActivity.LaunchMode
|
||||||
|
.LAUNCH_MODE_CHOOSE_SAVED_WIFI_NETWORK.getMode());
|
||||||
|
mActivityRule.launchActivity(intent);
|
||||||
|
|
||||||
|
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchActivity_noLaunchMode_shouldFinishActivityWithResultCodeCanceled() {
|
||||||
// If we do not specify launch mode, the activity will finish itself right away
|
// If we do not specify launch mode, the activity will finish itself right away
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
mActivityRule.launchActivity(intent);
|
mActivityRule.launchActivity(intent);
|
||||||
|
@@ -47,8 +47,9 @@ public class WifiDppQrCodeScannerFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLeftButton_shouldFinishActivityWithResultCodeCanceled() {
|
public void leftButton_shouldFinishActivityWithResultCodeCanceled() {
|
||||||
onView(withText("Cancel")).perform(click());
|
onView(withText("Cancel")).perform(click());
|
||||||
|
|
||||||
assertThat(mActivityRule.getActivityResult().getResultCode()).
|
assertThat(mActivityRule.getActivityResult().getResultCode()).
|
||||||
isEqualTo(Activity.RESULT_CANCELED);
|
isEqualTo(Activity.RESULT_CANCELED);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user