Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ad687a0 authored by Russell Brenner's avatar Russell Brenner Committed by Android (Google) Code Review
Browse files

Merge "Refactor setup wizard-related code"

parents 09626a8a d3446c57
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@
        </activity>

        <activity android:name=".wifi.WifiSetupActivity"
                android:taskAffinity="com.android.wizard"
                android:theme="@style/SetupWizardWifiTheme"
                android:label="@string/wifi_setup_wizard_title"
                android:icon="@drawable/empty_icon"
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
-->
<view
    xmlns:android="http://schemas.android.com/apk/res/android"
    class="com.android.settings.wifi.WifiSettings$ProportionalOuterFrame"
    class="com.android.settings.widget.ProportionalOuterFrame"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

+63 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 Google Inc.
 *
 * 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.widget;

import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;

import com.android.settings.R;

/**
 * Used as the outer frame of all setup wizard pages that need to adjust their margins based
 * on the total size of the available display. (e.g. side margins set to 10% of total width.)
 */
public class ProportionalOuterFrame extends RelativeLayout {
    public ProportionalOuterFrame(Context context) {
        super(context);
    }

    public ProportionalOuterFrame(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ProportionalOuterFrame(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    /**
     * Set our margins and title area height proportionally to the available display size
     */
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        final int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
        final int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
        final Resources res = getContext().getResources();
        final float titleHeight = res.getFraction(R.dimen.setup_title_height, 1, 1);
        final float sideMargin = res.getFraction(R.dimen.setup_border_width, 1, 1);
        final int bottom = res.getDimensionPixelSize(R.dimen.setup_margin_bottom);
        setPaddingRelative((int) (parentWidth * sideMargin), 0,
                (int) (parentWidth * sideMargin), bottom);
        final View title = findViewById(R.id.title_area);
        if (title != null) {
            title.setMinimumHeight((int) (parentHeight * titleHeight));
        }
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}
+8 −2
Original line number Diff line number Diff line
@@ -21,22 +21,28 @@ import com.android.settings.wifi.p2p.WifiP2pSettings;

import android.content.Intent;

import java.lang.Class;

public class WifiPickerActivity extends SettingsActivity implements ButtonBarHandler {

    @Override
    public Intent getIntent() {
        Intent modIntent = new Intent(super.getIntent());
        if (!modIntent.hasExtra(EXTRA_SHOW_FRAGMENT)) {
            modIntent.putExtra(EXTRA_SHOW_FRAGMENT, WifiSettings.class.getName());
            modIntent.putExtra(EXTRA_SHOW_FRAGMENT, getWifiSettingsClass().getName());
        }
        return modIntent;
    }

    @Override
    protected boolean isValidFragment(String fragmentName) {
        if (WifiSettings.class.getName().equals(fragmentName)
        if (getWifiSettingsClass().getName().equals(fragmentName)
                || WifiP2pSettings.class.getName().equals(fragmentName)
                || AdvancedWifiSettings.class.getName().equals(fragmentName)) return true;
        return false;
    }

    /* package */ Class getWifiSettingsClass() {
        return WifiSettings.class;
    }
}
 No newline at end of file
+46 −326

File changed.

Preview size limit exceeded, changes collapsed.

Loading