Refactor WiFi code around XL setup
Major: - move SetupWizard-related codes to WifiSettingsForSetupWizardXL as much as possible - stop using Preference for configurinig wifi network. We use WifiConfigUiForSetupWizardXL instead, which is base on a bare View. Minor: - change button handling code expecting better readability. - hide Detail button. - modify strings a bit. - add logs Bug: 3175016 Change-Id: I5b29917af73aac6a82e13ba846a9d5085f9bd523
This commit is contained in:
162
src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
Normal file
162
src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
/**
|
||||
* Shows simplified UI for configuring a wifi network. Used only in SetupWizard for XLarge
|
||||
* screen.
|
||||
*/
|
||||
public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase {
|
||||
private static final String TAG = "WifiConfigPreference";
|
||||
|
||||
private Button mConnectButton;
|
||||
private Button mForgetButton;
|
||||
private Button mCancelButton;
|
||||
|
||||
private final Activity mActivity;
|
||||
private View mView;
|
||||
private WifiConfigController mController;
|
||||
private AccessPoint mAccessPoint;
|
||||
private boolean mEdit;
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
/**
|
||||
* @param activity Activity which creates this object.
|
||||
* @param parent Parent ViewGroup (typically some layout) holding a view object created by
|
||||
* this object
|
||||
* @param accessPoint target AccessPoint to be configured.
|
||||
* @param edit
|
||||
*/
|
||||
public WifiConfigUiForSetupWizardXL(
|
||||
Activity activity, ViewGroup parent, AccessPoint accessPoint, boolean edit) {
|
||||
mActivity = activity;
|
||||
mConnectButton = (Button)activity.findViewById(R.id.wifi_setup_connect);
|
||||
mForgetButton = (Button)activity.findViewById(R.id.wifi_setup_forget);
|
||||
mCancelButton = (Button)activity.findViewById(R.id.wifi_setup_cancel);
|
||||
mAccessPoint = accessPoint;
|
||||
mEdit = edit;
|
||||
mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
mView = mInflater.inflate(R.layout.wifi_config_ui_for_setup_wizard, parent, false);
|
||||
mController = new WifiConfigController(this, mView, mAccessPoint, edit);
|
||||
trySetFocusAndLaunchSoftInput(R.id.password);
|
||||
}
|
||||
|
||||
private void trySetFocusAndLaunchSoftInput(int id) {
|
||||
final View viewToBeFocused = mView.findViewById(id);
|
||||
if (viewToBeFocused != null && viewToBeFocused.getVisibility() == View.VISIBLE) {
|
||||
viewToBeFocused.requestFocus();
|
||||
// TODO: doesn't work.
|
||||
if (viewToBeFocused instanceof EditText) {
|
||||
Log.d(TAG, "Focused View is EditText. We try showing the software keyboard");
|
||||
// viewToBeFocused.performClick();
|
||||
final InputMethodManager inputMethodManager = (InputMethodManager)
|
||||
mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
inputMethodManager.showSoftInput(viewToBeFocused, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return mView;
|
||||
}
|
||||
|
||||
public AccessPoint getAccessPoint() {
|
||||
return mAccessPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WifiConfigController getController() {
|
||||
return mController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEdit() {
|
||||
return mEdit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayoutInflater getLayoutInflater() {
|
||||
return mInflater;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Button getSubmitButton() {
|
||||
return mConnectButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Button getForgetButton() {
|
||||
return mForgetButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Button getCancelButton() {
|
||||
return mCancelButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubmitButton(CharSequence text) {
|
||||
mConnectButton.setVisibility(View.VISIBLE);
|
||||
mConnectButton.setText(text);
|
||||
|
||||
// test
|
||||
mForgetButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForgetButton(CharSequence text) {
|
||||
// In XL setup screen, we won't show Forget button for simplifying the UI.
|
||||
// mForgetButton.setVisibility(View.VISIBLE);
|
||||
// mForgetButton.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelButton(CharSequence text) {
|
||||
mCancelButton.setVisibility(View.VISIBLE);
|
||||
// We don't want "cancel" label given from caller.
|
||||
// mCancelButton.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return mActivity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(int id) {
|
||||
Log.d(TAG, "Ignoring setTitle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(CharSequence title) {
|
||||
Log.d(TAG, "Ignoring setTitle");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user