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

Commit 59bce44a authored by Michael Kwan's avatar Michael Kwan Committed by Android (Google) Code Review
Browse files

Merge "Modified AlertController to allow themes to specify custom implementation." into nyc-mr1-dev

parents 8295332d cc6e6f0e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ public class AlertDialog extends Dialog implements DialogInterface {
                createContextThemeWrapper);

        mWindow.alwaysReadCloseOnTouchAttr();
        mAlert = new AlertController(getContext(), this, getWindow());
        mAlert = AlertController.create(getContext(), this, getWindow());
    }

    static int resolveDialogTheme(Context context, int themeResId) {
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public abstract class AlertActivity extends Activity implements DialogInterface
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mAlert = new AlertController(this, this, getWindow());
        mAlert = AlertController.create(this, this, getWindow());
        mAlertParams = new AlertController.AlertParams(this);
    }

+19 −7
Original line number Diff line number Diff line
@@ -64,11 +64,11 @@ public class AlertController {

    private final Context mContext;
    private final DialogInterface mDialogInterface;
    private final Window mWindow;
    protected final Window mWindow;

    private CharSequence mTitle;
    private CharSequence mMessage;
    private ListView mListView;
    protected CharSequence mMessage;
    protected ListView mListView;
    private View mView;

    private int mViewLayoutResId;
@@ -91,14 +91,14 @@ public class AlertController {
    private CharSequence mButtonNeutralText;
    private Message mButtonNeutralMessage;

    private ScrollView mScrollView;
    protected ScrollView mScrollView;

    private int mIconId = 0;
    private Drawable mIcon;

    private ImageView mIconView;
    private TextView mTitleView;
    private TextView mMessageView;
    protected TextView mMessageView;
    private View mCustomTitleView;

    private boolean mForceInverseBackground;
@@ -176,7 +176,19 @@ public class AlertController {
        return outValue.data != 0;
    }

    public AlertController(Context context, DialogInterface di, Window window) {
    public static final AlertController create(Context context, DialogInterface di, Window window) {
        final TypedArray a = context.obtainStyledAttributes(
                null, R.styleable.AlertDialog, R.attr.alertDialogStyle, 0);
        int controllerType = a.getInt(R.styleable.AlertDialog_controllerType, 0);
        a.recycle();

        switch (controllerType) {
            default:
                return new AlertController(context, di, window);
        }
    }

    protected AlertController(Context context, DialogInterface di, Window window) {
        mContext = context;
        mDialogInterface = di;
        mWindow = window;
@@ -643,7 +655,7 @@ public class AlertController {
        }
    }

    private void setupContent(ViewGroup contentPanel) {
    protected void setupContent(ViewGroup contentPanel) {
        mScrollView = (ScrollView) contentPanel.findViewById(R.id.scrollView);
        mScrollView.setFocusable(false);

+7 −0
Original line number Diff line number Diff line
@@ -2046,6 +2046,13 @@ i
        <attr name="showTitle" format="boolean" />
        <!-- @hide Whether fullDark, etc. should use default values if null. -->
        <attr name="needsDefaultBackgrounds" format="boolean" />
        <!-- @hide Workaround until we replace AlertController with custom layout. -->
        <attr name="controllerType">
            <!-- The default controller. -->
            <enum name="normal" value="0" />
            <!-- Controller for micro specific layout. -->
            <enum name="micro" value="1" />
        </attr>
    </declare-styleable>

    <!-- @hide -->
+1 −1
Original line number Diff line number Diff line
@@ -1145,7 +1145,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
        public GlobalActionsDialog(Context context, AlertParams params) {
            super(context, getDialogTheme(context));
            mContext = getContext();
            mAlert = new AlertController(mContext, this, getWindow());
            mAlert = AlertController.create(mContext, this, getWindow());
            mAdapter = (MyAdapter) params.mAdapter;
            mWindowTouchSlop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
            params.apply(mAlert);