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

Commit 16204307 authored by Craig Stout's avatar Craig Stout Committed by Android (Google) Code Review
Browse files

Merge "AlertDialog and AppError themes for TV."

parents 16fa43a2 4c0cb8a5
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -93,6 +93,18 @@ public class AlertDialog extends Dialog implements DialogInterface {
     */
    public static final int THEME_DEVICE_DEFAULT_LIGHT = 5;

    /**
     * No layout hint.
     * @hide
     */
    public static final int LAYOUT_HINT_NONE = 0;

    /**
     * Hint layout to the side.
     * @hide
     */
    public static final int LAYOUT_HINT_SIDE = 1;
    
    protected AlertDialog(Context context) {
        this(context, resolveDialogTheme(context, 0), true);
    }
@@ -207,6 +219,14 @@ public class AlertDialog extends Dialog implements DialogInterface {
        mAlert.setView(view, viewSpacingLeft, viewSpacingTop, viewSpacingRight, viewSpacingBottom);
    }

    /**
     * Internal api to allow hinting for the best button panel layout.
     * @hide
     */
    void setButtonPanelLayoutHint(int layoutHint) {
        mAlert.setButtonPanelLayoutHint(layoutHint);
    }

    /**
     * Set a message to be sent when a button is pressed.
     * 
+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener,
                (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.date_picker_dialog, null);
        setView(view);
        setButtonPanelLayoutHint(LAYOUT_HINT_SIDE);
        mDatePicker = (DatePicker) view.findViewById(R.id.datePicker);
        mDatePicker.init(year, monthOfYear, dayOfMonth, this);
        updateTitle(year, monthOfYear, dayOfMonth);
+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ public class TimePickerDialog extends AlertDialog
                (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.time_picker_dialog, null);
        setView(view);
        setButtonPanelLayoutHint(LAYOUT_HINT_SIDE);
        mTimePicker = (TimePicker) view.findViewById(R.id.timePicker);

        // Initialize state
+26 −1
Original line number Diff line number Diff line
@@ -123,11 +123,14 @@ public class AlertController {
    private int mCheckedItem = -1;

    private int mAlertDialogLayout;
    private int mButtonPanelSideLayout;
    private int mListLayout;
    private int mMultiChoiceItemLayout;
    private int mSingleChoiceItemLayout;
    private int mListItemLayout;

    private int mButtonPanelLayoutHint = AlertDialog.LAYOUT_HINT_NONE;
    
    private Handler mHandler;

    private final View.OnClickListener mButtonHandler = new View.OnClickListener() {
@@ -199,6 +202,9 @@ public class AlertController {

        mAlertDialogLayout = a.getResourceId(com.android.internal.R.styleable.AlertDialog_layout,
                com.android.internal.R.layout.alert_dialog);
        mButtonPanelSideLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_buttonPanelSideLayout, 0);

        mListLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_listLayout,
                com.android.internal.R.layout.select_dialog);
@@ -240,11 +246,23 @@ public class AlertController {
    public void installContent() {
        /* We use a custom title so never request a window title */
        mWindow.requestFeature(Window.FEATURE_NO_TITLE);
        mWindow.setContentView(mAlertDialogLayout);
        int contentView = selectContentView();
        mWindow.setContentView(contentView);
        setupView();
        setupDecor();
    }

    private int selectContentView() {
        if (mButtonPanelSideLayout == 0) {
            return mAlertDialogLayout;
        }
        if (mButtonPanelLayoutHint == AlertDialog.LAYOUT_HINT_SIDE) {
            return mButtonPanelSideLayout;
        }
        // TODO: use layout hint side for long messages/lists
        return mAlertDialogLayout;
    }
    
    public void setTitle(CharSequence title) {
        mTitle = title;
        if (mTitleView != null) {
@@ -298,6 +316,13 @@ public class AlertController {
        mViewSpacingBottom = viewSpacingBottom;
    }

    /**
     * Sets a hint for the best button panel layout.
     */
    public void setButtonPanelLayoutHint(int layoutHint) {
        mButtonPanelLayoutHint = layoutHint;
    }

    /**
     * Sets a click listener or a message to be sent when the button is clicked.
     * You only need to pass one of {@code listener} or {@code msg}.
+131 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2014, 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.
*/
-->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parentPanel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/leanback_alert_dialog_horizontal_margin"
    android:layout_marginRight="@dimen/leanback_alert_dialog_horizontal_margin"
    android:layout_marginTop="@dimen/leanback_alert_dialog_vertical_margin"
    android:layout_marginBottom="@dimen/leanback_alert_dialog_vertical_margin"
    android:orientation="vertical">

    <LinearLayout android:id="@+id/topPanel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <LinearLayout android:id="@+id/title_template"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="center_vertical|start"
            android:minHeight="@dimen/alert_dialog_title_height"
            android:layout_marginStart="16dip"
            android:layout_marginEnd="16dip">
            <ImageView android:id="@+id/icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingEnd="8dip"
                android:src="@null" />
            <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle"
                style="?android:attr/windowTitleStyle"
                android:singleLine="true"
                android:ellipsize="end"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAlignment="viewStart" />
        </LinearLayout>
        <!-- If the client uses a customTitle, it will be added here. -->
    </LinearLayout>

    <LinearLayout android:id="@+id/contentPanel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:minHeight="64dp">
        <ScrollView android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipToPadding="false">
            <TextView android:id="@+id/message"
                style="?android:attr/textAppearanceMedium"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingStart="16dip"
                android:paddingEnd="16dip"
                android:paddingTop="8dip"
                android:paddingBottom="8dip"/>
        </ScrollView>
    </LinearLayout>

    <FrameLayout android:id="@+id/customPanel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:minHeight="64dp">
        <FrameLayout android:id="@+android:id/custom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </FrameLayout>

    <LinearLayout android:id="@+id/buttonPanel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="@dimen/alert_dialog_button_bar_height"
        android:orientation="vertical">
        <LinearLayout
            style="?android:attr/buttonBarStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layoutDirection="locale"
            android:measureWithLargestChild="true">
            <Button android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_gravity="start"
                android:layout_weight="1"
                android:maxLines="2"
                style="?android:attr/buttonBarButtonStyle"
                android:textSize="14sp"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                android:layout_height="wrap_content" />
            <Button android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:maxLines="2"
                style="?android:attr/buttonBarButtonStyle"
                android:textSize="14sp"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                android:layout_height="wrap_content" />
            <Button android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_gravity="end"
                android:layout_weight="1"
                android:maxLines="2"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                style="?android:attr/buttonBarButtonStyle"
                android:textSize="14sp"
                android:layout_height="wrap_content" />
        </LinearLayout>
     </LinearLayout>
</LinearLayout>
Loading