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

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

Merge "Initial update of Micro theme for Material design." into nyc-mr1-dev

parents 8dc27182 246caace
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import android.widget.TextView;
import java.lang.ref.WeakReference;

public class AlertController {
    public static final int MICRO = 1;

    private final Context mContext;
    private final DialogInterface mDialogInterface;
@@ -183,6 +184,8 @@ public class AlertController {
        a.recycle();

        switch (controllerType) {
            case MICRO:
                return new MicroAlertController(context, di, window);
            default:
                return new AlertController(context, di, window);
        }
@@ -1128,6 +1131,7 @@ public class AlertController {
                listView.setOnItemClickListener(new OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                        position -= listView.getHeaderViewsCount();
                        mOnClickListener.onClick(dialog.mDialogInterface, position);
                        if (!mIsSingleChoice) {
                            dialog.mDialogInterface.dismiss();
@@ -1138,6 +1142,7 @@ public class AlertController {
                listView.setOnItemClickListener(new OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                        position -= listView.getHeaderViewsCount();
                        if (mCheckedItems != null) {
                            mCheckedItems[position] = listView.isItemChecked(position);
                        }
+85 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.
 */

package com.android.internal.app;

import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.AbsListView;

import com.android.internal.app.AlertController;
import com.android.internal.R;

public class MicroAlertController extends AlertController {
    public MicroAlertController(Context context, DialogInterface di, Window window) {
        super(context, di, window);
    }

    @Override
    protected void setupContent(ViewGroup contentPanel) {
        // Special case for small screen - the scroll view is higher in hierarchy
        mScrollView = (ScrollView) mWindow.findViewById(R.id.scrollView);

        // Special case for users that only want to display a String
        mMessageView = (TextView) contentPanel.findViewById(R.id.message);
        if (mMessageView == null) {
            return;
        }

        if (mMessage != null) {
            mMessageView.setText(mMessage);
        } else {
            // no message, remove associated views
            mMessageView.setVisibility(View.GONE);
            contentPanel.removeView(mMessageView);

            if (mListView != null) {
                // has ListView, swap ScrollView with ListView

                // move topPanel into header of ListView
                View topPanel = mScrollView.findViewById(R.id.topPanel);
                ((ViewGroup) topPanel.getParent()).removeView(topPanel);
                topPanel.setLayoutParams(
                        new AbsListView.LayoutParams(topPanel.getLayoutParams()));
                mListView.addHeaderView(topPanel, null, false);

                // move buttonPanel into footer of ListView
                View buttonPanel = mScrollView.findViewById(R.id.buttonPanel);
                ((ViewGroup) buttonPanel.getParent()).removeView(buttonPanel);
                buttonPanel.setLayoutParams(
                        new AbsListView.LayoutParams(buttonPanel.getLayoutParams()));
                mListView.addFooterView(buttonPanel, null, false);

                // swap ScrollView w/ ListView
                final ViewGroup scrollParent = (ViewGroup) mScrollView.getParent();
                final int childIndex = scrollParent.indexOfChild(mScrollView);
                scrollParent.removeViewAt(childIndex);
                scrollParent.addView(mListView, childIndex,
                        new ViewGroup.LayoutParams(
                                ViewGroup.LayoutParams.MATCH_PARENT,
                                ViewGroup.LayoutParams.MATCH_PARENT));
            } else {
                // no content, just hide everything
                contentPanel.setVisibility(View.GONE);
            }
        }
    }
}
+41 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2016 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:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="top|center_horizontal"
        android:minHeight="@dimen/alert_dialog_title_height">
    <ImageView android:id="@+id/icon"
            android:maxHeight="24dp"
            android:maxWidth="24dp"
            android:layout_marginTop="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginBottom="8dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@null" />
    <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle"
            style="?android:attr/windowTitleStyle"
            android:ellipsize="end"
            android:layout_marginStart="8dp"
            android:layout_marginBottom="8dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAlignment="viewStart" />
</LinearLayout>
+38 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2016 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
  -->
<FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="top|center_horizontal"
        android:minHeight="@dimen/alert_dialog_title_height">
    <ImageView android:id="@+id/icon"
            android:maxHeight="24dp"
            android:maxWidth="24dp"
            android:layout_marginTop="12dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@null" />
    <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle"
            style="?android:attr/windowTitleStyle"
            android:ellipsize="end"
            android:layout_marginTop="36dp"
            android:layout_marginBottom="4dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAlignment="center" />
</FrameLayout>
+91 −118
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2014 The Android Open Source Project
  ~ Copyright (C) 2016 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.
@@ -14,127 +14,100 @@
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->

<LinearLayout
<FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/parentPanel"
        android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:layout_gravity="center"
    android:orientation="vertical">

    <LinearLayout android:id="@+id/topPanel"
        android:layout_height="match_parent">
    <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <View android:id="@+id/titleDividerTop"
            android:layout_height="match_parent">
        <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
            android:layout_height="2dip"
            android:visibility="gone"
            android:background="@android:color/holo_blue_light" />
        <LinearLayout android:id="@+id/title_template"
                android:layout_height="wrap_content">
            <!-- Top Panel -->
            <FrameLayout
                    android:paddingLeft="@dimen/dialog_padding_micro"
                    android:paddingRight="@dimen/dialog_padding_micro"
                    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:id="@+id/topPanel">
                <include android:id="@+id/title_template"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                android:textAlignment="viewStart" />
        </LinearLayout>
        <View android:id="@+id/titleDivider"
            android:layout_width="match_parent"
            android:layout_height="2dip"
            android:visibility="gone"
            android:background="@android:color/holo_blue_light" />
        <!-- If the client uses a customTitle, it will be added here. -->
    </LinearLayout>
                        layout="@layout/alert_dialog_header_micro"/>
            </FrameLayout>

    <LinearLayout android:id="@+id/contentPanel"
            <!-- Content Panel -->
            <FrameLayout 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:layout_height="match_parent"
                    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:textAppearance="@style/TextAppearance.Micro.AlertDialog.Message"
                        android:paddingStart="@dimen/dialog_padding_micro"
                        android:paddingEnd="@dimen/dialog_padding_micro"
                        android:paddingTop="8dip"
                        android:paddingBottom="8dip"/>
        </ScrollView>
    </LinearLayout>
            </FrameLayout>

            <!-- Custom Panel, to replace content panel if needed -->
            <FrameLayout android:id="@+id/customPanel"
                    android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
                    android:layout_height="match_parent"
                    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"
            <!-- Button Panel -->
            <FrameLayout
                    android:id="@+id/buttonPanel"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
        android:minHeight="@dimen/alert_dialog_button_bar_height"
        android:orientation="vertical"
                        android:divider="?android:attr/dividerHorizontal"
                        android:showDividers="beginning"
        android:dividerPadding="0dip">
        <LinearLayout
                        android:dividerPadding="0dip"
                        android:orientation="vertical"
                        android:minHeight="@dimen/alert_dialog_button_bar_height"
                        android:paddingBottom="@dimen/dialog_padding_micro"
                        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"
                    <Button android:id="@+id/button1"
                            android:layout_gravity="start"
                            android:layout_weight="1"
                android:maxLines="2"
                            android:layout_marginLeft="@dimen/dialog_padding_micro"
                            android:layout_marginRight="@dimen/dialog_padding_micro"
                            style="?android:attr/buttonBarButtonStyle"
                android:textSize="14sp"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" />
                    <Button android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_gravity="center_horizontal"
                            android:layout_gravity="start"
                            android:layout_weight="1"
                android:maxLines="2"
                            android:layout_marginLeft="@dimen/dialog_padding_micro"
                            android:layout_marginRight="@dimen/dialog_padding_micro"
                            style="?android:attr/buttonBarButtonStyle"
                android:textSize="14sp"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" />
            <Button android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_gravity="end"
                    <Button android:id="@+id/button2"
                            android:layout_gravity="start"
                            android:layout_weight="1"
                android:maxLines="2"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                            android:layout_marginLeft="@dimen/dialog_padding_micro"
                            android:layout_marginRight="@dimen/dialog_padding_micro"
                            style="?android:attr/buttonBarButtonStyle"
                android:textSize="14sp"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" />
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
</LinearLayout>
    </ScrollView>
</FrameLayout>
Loading