Files
app_Settings/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
Arc Wang 8e3c49123d [Wi-Fi DPP] Refine Wi-Fi DPP UI layouts with SUW library
1. Use GlifLayout in all fragments
2. Fragments use 32dp icon instead of 48 dp
3. Replace ScrollView & ProgressBar & Header & Footer of original layout with GlifLayout design
4. Remove ActionBar (no more back button on screen top)

Bug: 129021867
Test: manual
Change-Id: I2fda48cb7f7819b2c8dd85c10d39e1f187463bd8
2019-05-21 13:59:39 +08:00

116 lines
4.0 KiB
Java

/*
* 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.app.settings.SettingsEnums;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.core.InstrumentedActivity;
/**
* To provision "this" device with specified Wi-Fi network.
*
* To use intent action {@code ACTION_ENROLLEE_QR_CODE_SCANNER}, specify the SSID string of the
* Wi-Fi network to be provisioned in {@code WifiDppUtils.EXTRA_WIFI_SSID}.
*/
public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
WifiDppQrCodeScannerFragment.OnScanWifiDppSuccessListener {
private static final String TAG = "WifiDppEnrolleeActivity";
public static final String ACTION_ENROLLEE_QR_CODE_SCANNER =
"android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER";
private FragmentManager mFragmentManager;
@Override
public int getMetricsCategory() {
return SettingsEnums.SETTINGS_WIFI_DPP_ENROLLEE;
}
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent());
theme.applyStyle(R.style.SetupWizardPartnerResource, /* force */ true);
super.onApplyThemeResource(theme, resid, first);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wifi_dpp_activity);
mFragmentManager = getSupportFragmentManager();
if (savedInstanceState == null) {
handleIntent(getIntent());
}
}
private void handleIntent(Intent intent) {
switch (intent.getAction()) {
case ACTION_ENROLLEE_QR_CODE_SCANNER:
String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
showQrCodeScannerFragment(/* addToBackStack */ false, ssid);
break;
default:
Log.e(TAG, "Launch with an invalid action");
finish();
}
}
private void showQrCodeScannerFragment(boolean addToBackStack, String ssid) {
WifiDppQrCodeScannerFragment fragment =
(WifiDppQrCodeScannerFragment) mFragmentManager.findFragmentByTag(
WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
if (fragment == null) {
fragment = new WifiDppQrCodeScannerFragment(ssid);
} else {
if (fragment.isVisible()) {
return;
}
// When the fragment in back stack but not on top of the stack, we can simply pop
// stack because current fragment transactions are arranged in an order
mFragmentManager.popBackStackImmediate();
return;
}
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
if (addToBackStack) {
fragmentTransaction.addToBackStack(/* name */ null);
}
fragmentTransaction.commit();
}
@Override
public void onScanWifiDppSuccess(WifiQrCode wifiQrCode) {
// Do nothing
}
}