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

Commit 6cab5e82 authored by Alice Yang's avatar Alice Yang
Browse files

Fix bug where existing account not pre-checked

The fix was to call ListView.setItemChecked()
instead of ListView.setSelection() for setting radio button status.
Also refactored the code a bit so it's less verbose.

Bug 6588533

Change-Id: I8add072a0277183baec7c0d5634a28f2d3a28c5e
parent 593b4446
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
@@ -280,23 +279,16 @@ public class ChooseTypeAndAccountActivity extends Activity
        if (selectedAddNewAccount) {
            mSelectedItemIndex = mAccounts.size();
        }
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "mSelectedItemIndex is " + mSelectedItemIndex);
        }

        ViewGroup buttonBar = (ViewGroup) findViewById(R.id.button_bar);
        if (buttonBar != null) {
            mOkButton = (Button) buttonBar.findViewById(android.R.id.button2);
        if (mSelectedItemIndex != SELECTED_ITEM_NONE) {
                // If caller specified a selectedAccount, then display that as selected and enable
                // the "OK" button by default.
                list.setSelection(mSelectedItemIndex);
                mOkButton.setEnabled(true);
            } else {
                // Otherwise "OK" button is disabled since nothing is pre-selected.
                mOkButton.setEnabled(false);
            list.setItemChecked(mSelectedItemIndex, true);
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "List item " + mSelectedItemIndex + " should be selected");
            }
        }

        // Only enable "OK" button if something has been selected.
        mOkButton = (Button) findViewById(android.R.id.button2);
        mOkButton.setEnabled(mSelectedItemIndex != SELECTED_ITEM_NONE);
    }

    @Override