Skip to content

Commit

Permalink
Improve dialog layout
Browse files Browse the repository at this point in the history
Remove dependency on private resources.
  • Loading branch information
pranavpandey committed Sep 24, 2018
1 parent 3e4e009 commit 0a073fe
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 22 deletions.
6 changes: 3 additions & 3 deletions dynamic-support/src/main/res/layout/ads_alert_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:id="@+id/parentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start|left|top"
android:gravity="start|top"
android:orientation="vertical">

<include layout="@layout/ads_alert_dialog_title" />
Expand All @@ -40,7 +40,7 @@
<android.support.v4.widget.Space
android:id="@+id/textSpacerNoTitle"
android:layout_width="match_parent"
android:layout_height="@dimen/abc_dialog_padding_top_material"
android:layout_height="@dimen/add_dialog_margin_title_top"
android:visibility="gone" />

<View
Expand Down Expand Up @@ -86,7 +86,7 @@
<android.support.v4.widget.Space
android:id="@+id/textSpacerNoButtons"
android:layout_width="match_parent"
android:layout_height="@dimen/abc_dialog_padding_top_material"
android:layout_height="@dimen/add_dialog_margin_title_top"
android:visibility="gone" />

</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/buttonPanel"
style="?attr/buttonBarStyle"
android:layout_width="match_parent"
Expand Down
11 changes: 6 additions & 5 deletions dynamic-support/src/main/res/layout/ads_alert_dialog_title.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@
android:id="@+id/title_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|start|left"
android:gravity="center_vertical|start"
android:orientation="horizontal"
android:paddingLeft="?attr/dialogPreferredPadding"
android:paddingRight="?attr/dialogPreferredPadding"
android:paddingTop="@dimen/abc_dialog_padding_top_material">
android:paddingTop="@dimen/add_dialog_margin_title_top">

<ImageView
android:id="@android:id/icon"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_marginEnd="8dip"
android:layout_marginRight="8dip"
android:contentDescription="@null"
android:scaleType="fitCenter"
android:src="@null"/>
android:src="@null" />

<android.support.v7.widget.DialogTitle
android:id="@+id/alertTitle"
Expand All @@ -60,7 +61,7 @@
<android.support.v4.widget.Space
android:id="@+id/titleDividerNoCustom"
android:layout_width="match_parent"
android:layout_height="@dimen/abc_dialog_title_divider_material"
android:visibility="gone"/>
android:layout_height="@dimen/add_dialog_margin_title_bottom"
android:visibility="gone" />

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
android:scrollbars="vertical"
android:textAlignment="viewStart"
android:gravity="start"
app:paddingBottomNoButtons="@dimen/abc_dialog_list_padding_bottom_no_buttons"
app:paddingTopNoTitle="@dimen/abc_dialog_list_padding_top_no_title"/>
app:paddingBottomNoButtons="@dimen/ads_dialog_list_margin_no_buttons_button"
app:paddingTopNoTitle="@dimen/ads_dialog_list_margin_no_title_top" />
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@

<com.pranavpandey.android.dynamic.support.widget.DynamicCheckedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?attr/textColorAlertDialogListItem"
android:gravity="center_vertical"
android:paddingLeft="@dimen/abc_select_dialog_padding_start_material"
android:paddingLeft="@dimen/ads_dialog_margin_select_start"
android:paddingRight="?attr/dialogPreferredPadding"
android:paddingStart="@dimen/abc_select_dialog_padding_start_material"
android:paddingStart="@dimen/ads_dialog_margin_select_start"
android:paddingEnd="?attr/dialogPreferredPadding"
android:drawableLeft="?android:attr/listChoiceIndicatorMultiple"
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
android:drawablePadding="20dp"
android:drawablePadding="@dimen/ads_dialog_margin_select_start"
android:ellipsize="marquee" />
37 changes: 37 additions & 0 deletions dynamic-support/src/main/res/layout/ads_dialog_select_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Pranav Pandey
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.
-->

<!--
This layout file is used by the AlertDialog when displaying a list of items.
This layout file is inflated and used as the TextView to display individual
items.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/listPreferredItemHeightSmall"
android:textAppearance="?attr/textAppearanceListItemSmall"
android:textColor="?attr/textColorAlertDialogListItem"
android:gravity="center_vertical"
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:paddingStart="?attr/listPreferredItemPaddingLeft"
android:paddingEnd="?attr/listPreferredItemPaddingRight"
android:ellipsize="marquee" />
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?attr/textColorAlertDialogListItem"
android:gravity="center_vertical"
android:paddingLeft="@dimen/abc_select_dialog_padding_start_material"
android:paddingLeft="@dimen/ads_dialog_margin_select_start"
android:paddingRight="?attr/dialogPreferredPadding"
android:paddingStart="@dimen/abc_select_dialog_padding_start_material"
android:paddingStart="@dimen/ads_dialog_margin_select_start"
android:paddingEnd="?attr/dialogPreferredPadding"
android:drawableLeft="?android:attr/listChoiceIndicatorSingle"
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
android:drawablePadding="20dp"
android:drawablePadding="@dimen/ads_dialog_margin_select_start"
android:ellipsize="marquee" />
5 changes: 5 additions & 0 deletions dynamic-support/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@
<!-- Dialog -->
<dimen name="ads_dialog_margin_start_end">24dp</dimen>
<dimen name="ads_dialog_margin_start_end_small">22dp</dimen>
<dimen name="ads_dialog_margin_select_start">20dp</dimen>
<dimen name="add_dialog_margin_title_top">18dp</dimen>
<dimen name="add_dialog_margin_title_bottom">12dp</dimen>
<dimen name="ads_dialog_margin_input">20dp</dimen>
<dimen name="ads_dialog_margin_small">10dp</dimen>
<dimen name="ads_dialog_list_margin_no_title_top">8dp</dimen>
<dimen name="ads_dialog_list_margin_no_buttons_button">8dp</dimen>
<dimen name="ads_dialog_font_size">@dimen/ads_font_size_small</dimen>
<dimen name="ads_dialog_font_size_title">@dimen/ads_font_size_medium</dimen>
<dimen name="ads_dialog_font_size_large_fixed">12dp</dimen>
Expand Down
8 changes: 4 additions & 4 deletions dynamic-support/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@

<style name="Base.DynamicApp.AlertDialog" parent="android:Widget">
<item name="android:layout">@layout/ads_alert_dialog</item>
<item name="listLayout">@layout/ads_alert_dialog_list</item>
<item name="listItemLayout">@layout/select_dialog_item_material</item>
<item name="multiChoiceItemLayout">@layout/ads_alert_dialog_multi_choice</item>
<item name="singleChoiceItemLayout">@layout/ads_alert_dialog_single_choice</item>
<item name="listLayout">@layout/ads_dialog_list</item>
<item name="listItemLayout">@layout/ads_dialog_select_item</item>
<item name="multiChoiceItemLayout">@layout/ads_dialog_multi_choice</item>
<item name="singleChoiceItemLayout">@layout/ads_dialog_single_choice</item>
</style>

<style name="Theme.DynamicApp" parent="Base.DynamicApp.NoActionBar" />
Expand Down

0 comments on commit 0a073fe

Please sign in to comment.