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

Commit d2b64f33 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Fix bug #15001610 Java crash in settings is observed while adding Google account on wiped device

- update Settings main layout to be able to show the Buttons
- make WifiPickerActivity a SettingsActivity and remove dead code
- fix reference to Buttons for using the Settings IDs instead
of the Framework ones

Change-Id: I23bfd1b8290fc007e6e80aa9a6297e55e7f6004e
parent 38f2b27c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -24,8 +24,9 @@

    <LinearLayout
            android:orientation="vertical"
            android:layout_height="match_parent"
            android:layout_width="match_parent">
            android:layout_height="0px"
            android:layout_width="match_parent"
            android:layout_weight="1">

        <com.android.settings.widget.SwitchBar android:id="@+id/switch_bar"
                  android:layout_height="?android:attr/actionBarSize"
@@ -37,7 +38,6 @@
                android:id="@+id/prefs"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                />

    </LinearLayout>
+4 −4
Original line number Diff line number Diff line
@@ -515,25 +515,25 @@ public class SettingsActivity extends Activity
        Intent intent = getIntent();
        if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {

            View buttonBar = findViewById(com.android.internal.R.id.button_bar);
            View buttonBar = findViewById(R.id.button_bar);
            if (buttonBar != null) {
                buttonBar.setVisibility(View.VISIBLE);

                Button backButton = (Button)findViewById(com.android.internal.R.id.back_button);
                Button backButton = (Button)findViewById(R.id.back_button);
                backButton.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        setResult(RESULT_CANCELED);
                        finish();
                    }
                });
                Button skipButton = (Button)findViewById(com.android.internal.R.id.skip_button);
                Button skipButton = (Button)findViewById(R.id.skip_button);
                skipButton.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        setResult(RESULT_OK);
                        finish();
                    }
                });
                mNextButton = (Button)findViewById(com.android.internal.R.id.next_button);
                mNextButton = (Button)findViewById(R.id.next_button);
                mNextButton.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        setResult(RESULT_OK);
+2 −68
Original line number Diff line number Diff line
@@ -16,22 +16,12 @@
package com.android.settings.wifi;

import com.android.settings.ButtonBarHandler;
import com.android.settings.SettingsActivity;
import com.android.settings.wifi.p2p.WifiP2pSettings;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.widget.Button;

public class WifiPickerActivity extends PreferenceActivity implements ButtonBarHandler {

    // Same as what are in PreferenceActivity as private.
    private static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar";
    private static final String EXTRA_PREFS_SET_NEXT_TEXT = "extra_prefs_set_next_text";
    private static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text";
    private static final String EXTRA_WIFI_SHOW_ACTION_BAR = "wifi_show_action_bar";
    private static final String EXTRA_WIFI_SHOW_MENUS = "wifi_show_menus";
public class WifiPickerActivity extends SettingsActivity implements ButtonBarHandler {

    @Override
    public Intent getIntent() {
@@ -39,7 +29,6 @@ public class WifiPickerActivity extends PreferenceActivity implements ButtonBarH
        if (!modIntent.hasExtra(EXTRA_SHOW_FRAGMENT)) {
            modIntent.putExtra(EXTRA_SHOW_FRAGMENT, WifiSettings.class.getName());
        }
        modIntent.putExtra(EXTRA_NO_HEADERS, true);
        return modIntent;
    }

@@ -50,59 +39,4 @@ public class WifiPickerActivity extends PreferenceActivity implements ButtonBarH
                || AdvancedWifiSettings.class.getName().equals(fragmentName)) return true;
        return false;
    }

    /**
     * Almost dead copy of
     * {@link PreferenceActivity#startWithFragment(String, Bundle, Fragment, int)}, except this has
     * additional codes for button bar handling.
     */
    @Override
    public void startWithFragment(String fragmentName, Bundle args,
            Fragment resultTo, int resultRequestCode) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setClass(this, getClass());
        intent.putExtra(EXTRA_SHOW_FRAGMENT, fragmentName);
        intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
        intent.putExtra(EXTRA_NO_HEADERS, true);

        final Intent orgIntent = getIntent();
        if (orgIntent.hasExtra(EXTRA_PREFS_SHOW_BUTTON_BAR)) {
            intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR,
                    orgIntent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false));
        }
        if (orgIntent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) {
            intent.putExtra(EXTRA_PREFS_SET_NEXT_TEXT,
                    orgIntent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT));
        }
        if (orgIntent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) {
            intent.putExtra(EXTRA_PREFS_SET_BACK_TEXT,
                    orgIntent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT));
        }
        if (orgIntent.hasExtra(EXTRA_WIFI_SHOW_ACTION_BAR)) {
            intent.putExtra(EXTRA_WIFI_SHOW_ACTION_BAR,
                    orgIntent.getBooleanExtra(EXTRA_WIFI_SHOW_ACTION_BAR, true));
        }
        if (orgIntent.hasExtra(EXTRA_WIFI_SHOW_MENUS)) {
            intent.putExtra(EXTRA_WIFI_SHOW_MENUS,
                    orgIntent.getBooleanExtra(EXTRA_WIFI_SHOW_MENUS, true));
        }

        if (resultTo == null) {
            startActivity(intent);
        } else {
            resultTo.startActivityForResult(intent, resultRequestCode);
        }
    }

    @Override
    public boolean hasNextButton() {
        // PreferenceActivity#hasNextButton() is protected, so we need to expose it here.
        return super.hasNextButton();
    }

    @Override
    public Button getNextButton() {
        // PreferenceActivity#getNextButton() is protected, so we need to expose it here.
        return super.getNextButton();
    }
}
 No newline at end of file