From 4c8a1be4fba15e54ec082d5ff6cf1274c81d059a Mon Sep 17 00:00:00 2001 From: fengdai Date: Fri, 21 Nov 2014 21:29:26 +0800 Subject: [PATCH] Rename and do refactor, also update README file. --- README.md | 84 ++++++++++------- .../res/values-v11/adp_core_themes.xml | 6 +- .../res/values/adp_core_attrs.xml | 75 +++++++++++---- .../res/values/adp_core_styles.xml | 33 +++++++ .../res/values/adp_core_themes.xml | 10 +- .../res/layout/activity_my.xml | 6 ++ alertdialogpro-demo/res/values/styles.xml | 6 +- .../com/alertdialogpro/demo/MainActivity.java | 35 ++++++- .../res/layout/adp_alert_dialog_holo.xml | 2 +- .../layout/adp_select_dialog_item_holo.xml | 2 +- .../adp_select_dialog_multichoice_holo.xml | 2 +- .../adp_select_dialog_singlechoice_holo.xml | 2 +- .../res/values/adp_holo_attrs.xml | 5 + .../res/values/adp_holo_styles.xml | 65 ++++++++----- .../res/values/adp_holo_themes.xml | 38 ++++---- .../res/layout/adp_alert_dialog_material.xml | 1 + .../adp_select_dialog_item_material.xml | 2 +- ...adp_select_dialog_multichoice_material.xml | 2 +- ...dp_select_dialog_singlechoice_material.xml | 2 +- .../res/values-v11/adp_mtrl_themes.xml | 15 --- .../res/values-v14/adp_mtrl_styles.xml | 13 ++- .../res/values-v21/adp_mtrl_styles.xml | 10 +- .../res/values/adp_mtrl_styles.xml | 91 ++++++++++--------- .../res/values/adp_mtrl_themes.xml | 50 +++++----- 24 files changed, 347 insertions(+), 210 deletions(-) create mode 100644 alertdialogpro-core/res/values/adp_core_styles.xml delete mode 100644 alertdialogpro-theme-material/res/values-v11/adp_mtrl_themes.xml diff --git a/README.md b/README.md index aed7223..a4c9d92 100644 --- a/README.md +++ b/README.md @@ -55,50 +55,70 @@ Usage With AlertDialogPro, you can theme your dialog easily. - 1. If one of the built-in themes can meet almost your requirements, but you want some slight changes. You can use following attributes: + 1. If one of the built-in themes can meet almost your requirements, but you want to do some slight changes. You can use following attributes: ```xml - - @drawable/dialog_background_material_dark - - @style/DialogWindowTitle.Material - - @style/TextAppearance.Material.Subhead - - 48dip - - @color/primary_text_material_dark - - @style/TextAppearance.Material.Subhead - - @drawable/item_background_material_dark - - @null - - @style/Widget.Material.ListView - - @style/Widget.Material.ButtonBar - - @style/Widget.Material.Button - - ?attr/adpButtonBarButtonStyle - ?attr/adpButtonBarButtonStyle - ?attr/adpButtonBarButtonStyle + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ``` 2. You can also specify your own layout to the AlertDialogPro. This can be very useful when you want to use custom view or you want a very special dialog style. ```xml ``` diff --git a/alertdialogpro-core/res/values-v11/adp_core_themes.xml b/alertdialogpro-core/res/values-v11/adp_core_themes.xml index a28da71..bfecf30 100644 --- a/alertdialogpro-core/res/values-v11/adp_core_themes.xml +++ b/alertdialogpro-core/res/values-v11/adp_core_themes.xml @@ -1,13 +1,11 @@ - - diff --git a/alertdialogpro-core/res/values/adp_core_attrs.xml b/alertdialogpro-core/res/values/adp_core_attrs.xml index 6265537..791cf9b 100644 --- a/alertdialogpro-core/res/values/adp_core_attrs.xml +++ b/alertdialogpro-core/res/values/adp_core_attrs.xml @@ -1,32 +1,69 @@ + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/alertdialogpro-core/res/values/adp_core_styles.xml b/alertdialogpro-core/res/values/adp_core_styles.xml new file mode 100644 index 0000000..5416743 --- /dev/null +++ b/alertdialogpro-core/res/values/adp_core_styles.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/alertdialogpro-core/res/values/adp_core_themes.xml b/alertdialogpro-core/res/values/adp_core_themes.xml index d9e088c..525e381 100644 --- a/alertdialogpro-core/res/values/adp_core_themes.xml +++ b/alertdialogpro-core/res/values/adp_core_themes.xml @@ -1,19 +1,17 @@ - + - + - - - - - diff --git a/alertdialogpro-demo/src/com/alertdialogpro/demo/MainActivity.java b/alertdialogpro-demo/src/com/alertdialogpro/demo/MainActivity.java index 43d5d11..bda189e 100644 --- a/alertdialogpro-demo/src/com/alertdialogpro/demo/MainActivity.java +++ b/alertdialogpro-demo/src/com/alertdialogpro/demo/MainActivity.java @@ -1,5 +1,6 @@ package com.alertdialogpro.demo; +import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; @@ -32,16 +33,16 @@ public void onCheckedChanged(RadioGroup group, int checkedId) { mTheme = -1; break; case R.id.theme_material: - mTheme = R.style.AlertDialogProTheme_Material; + mTheme = R.style.Theme_AlertDialogPro_Material; break; case R.id.theme_material_light: - mTheme = R.style.AlertDialogProTheme_Material_Light; + mTheme = R.style.Theme_AlertDialogPro_Material_Light; break; case R.id.theme_holo: - mTheme = R.style.AlertDialogProTheme_Holo; + mTheme = R.style.Theme_AlertDialogPro_Holo; break; case R.id.theme_holo_light: - mTheme = R.style.AlertDialogProTheme_Holo_Light; + mTheme = R.style.Theme_AlertDialogPro_Holo_Light; break; default: break; @@ -54,6 +55,7 @@ public void onCheckedChanged(RadioGroup group, int checkedId) { findViewById(R.id.showMultiChoiceList).setOnClickListener(this); findViewById(R.id.showSingleChoiceList).setOnClickListener(this); findViewById(R.id.showCustomView).setOnClickListener(this); + findViewById(R.id.showNativeAlert).setOnClickListener(this); } @Override @@ -74,9 +76,34 @@ public void onClick(View v) { case R.id.showCustomView: showCustomViewDialog(); break; + case R.id.showNativeAlert: + showNativeAlert(); + break; } } + private void showNativeAlert() { + final String[] list = new String[]{"Holo theme", "Material theme", "Custom theme"}; + new AlertDialog.Builder(this).setTitle(R.string.app_name). + setMultiChoiceItems(list, + new boolean[]{false, false, false}, + new DialogInterface.OnMultiChoiceClickListener() { + @Override + public void onClick(DialogInterface dialog, int which, boolean isChecked) { + if (isChecked) { + mCheckedItems.add(list[which]); + } else { + mCheckedItems.remove(list[which]); + } + showToast(list[which] + " is " + (isChecked ? "checked" : "unchecked" + ".")); + } + }). + setNeutralButton("More info", new ButtonClickedListener("More info")). + setNegativeButton("Cancel", new ButtonClickedListener("Cancel")). + setPositiveButton("Choose", new ButtonClickedListener("Chose " + mCheckedItems.toString())).show(); + + } + // Show a message dialog private void showMessageAlertDialog() { new AlertDialogPro.Builder(this, mTheme).setTitle(R.string.app_name). diff --git a/alertdialogpro-theme-holo/res/layout/adp_alert_dialog_holo.xml b/alertdialogpro-theme-holo/res/layout/adp_alert_dialog_holo.xml index 57790c5..fe2f875 100644 --- a/alertdialogpro-theme-holo/res/layout/adp_alert_dialog_holo.xml +++ b/alertdialogpro-theme-holo/res/layout/adp_alert_dialog_holo.xml @@ -26,7 +26,7 @@ android:layout_marginLeft="16dip" android:layout_marginRight="16dip" android:gravity="center_vertical|start" - android:minHeight="?attr/adpTitleHeight" + android:minHeight="?attr/adpTitleMinHeight" android:orientation="horizontal"> + + + + + diff --git a/alertdialogpro-theme-holo/res/values/adp_holo_styles.xml b/alertdialogpro-theme-holo/res/values/adp_holo_styles.xml index 41a9f13..5aaa66f 100644 --- a/alertdialogpro-theme-holo/res/values/adp_holo_styles.xml +++ b/alertdialogpro-theme-holo/res/values/adp_holo_styles.xml @@ -1,9 +1,20 @@ - + + + + - - - - - + - - - - + + + diff --git a/alertdialogpro-theme-holo/res/values/adp_holo_themes.xml b/alertdialogpro-theme-holo/res/values/adp_holo_themes.xml index b4ef609..bda3f55 100644 --- a/alertdialogpro-theme-holo/res/values/adp_holo_themes.xml +++ b/alertdialogpro-theme-holo/res/values/adp_holo_themes.xml @@ -1,65 +1,63 @@ - - diff --git a/alertdialogpro-theme-material/res/layout/adp_alert_dialog_material.xml b/alertdialogpro-theme-material/res/layout/adp_alert_dialog_material.xml index b292804..6ba7062 100644 --- a/alertdialogpro-theme-material/res/layout/adp_alert_dialog_material.xml +++ b/alertdialogpro-theme-material/res/layout/adp_alert_dialog_material.xml @@ -16,6 +16,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical|start" + android:minHeight="?attr/adpTitleMinHeight" android:orientation="horizontal" android:paddingEnd="@dimen/adp_mtrl_alert_dialog_padding" android:paddingLeft="@dimen/adp_mtrl_alert_dialog_padding" diff --git a/alertdialogpro-theme-material/res/layout/adp_select_dialog_item_material.xml b/alertdialogpro-theme-material/res/layout/adp_select_dialog_item_material.xml index 1367ab2..1cfce94 100644 --- a/alertdialogpro-theme-material/res/layout/adp_select_dialog_item_material.xml +++ b/alertdialogpro-theme-material/res/layout/adp_select_dialog_item_material.xml @@ -5,7 +5,7 @@ android:layout_height="wrap_content" android:ellipsize="marquee" android:gravity="center_vertical" - android:minHeight="?adpListItemHeight" + android:minHeight="?attr/adpListItemMinHeight" android:paddingLeft="16dip" android:paddingRight="16dip" android:textAppearance="?attr/adpListItemTextAppearance" diff --git a/alertdialogpro-theme-material/res/layout/adp_select_dialog_multichoice_material.xml b/alertdialogpro-theme-material/res/layout/adp_select_dialog_multichoice_material.xml index 24ab209..82bc4e8 100644 --- a/alertdialogpro-theme-material/res/layout/adp_select_dialog_multichoice_material.xml +++ b/alertdialogpro-theme-material/res/layout/adp_select_dialog_multichoice_material.xml @@ -6,7 +6,7 @@ android:checkMark="?android:attr/listChoiceIndicatorMultiple" android:ellipsize="marquee" android:gravity="center_vertical" - android:minHeight="?attr/adpListItemHeight" + android:minHeight="?attr/adpListItemMinHeight" android:paddingLeft="16dip" android:paddingRight="16dip" android:textAppearance="?attr/adpListSingleChoiceTextAppearance" diff --git a/alertdialogpro-theme-material/res/layout/adp_select_dialog_singlechoice_material.xml b/alertdialogpro-theme-material/res/layout/adp_select_dialog_singlechoice_material.xml index fbeb2ad..5a3bb25 100644 --- a/alertdialogpro-theme-material/res/layout/adp_select_dialog_singlechoice_material.xml +++ b/alertdialogpro-theme-material/res/layout/adp_select_dialog_singlechoice_material.xml @@ -6,7 +6,7 @@ android:checkMark="?android:attr/listChoiceIndicatorSingle" android:ellipsize="marquee" android:gravity="center_vertical" - android:minHeight="?attr/adpListItemHeight" + android:minHeight="?attr/adpListItemMinHeight" android:paddingLeft="16dip" android:paddingRight="16dip" android:textAppearance="?attr/adpListMultiChoiceTextAppearance" diff --git a/alertdialogpro-theme-material/res/values-v11/adp_mtrl_themes.xml b/alertdialogpro-theme-material/res/values-v11/adp_mtrl_themes.xml deleted file mode 100644 index c5df39d..0000000 --- a/alertdialogpro-theme-material/res/values-v11/adp_mtrl_themes.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/alertdialogpro-theme-material/res/values-v14/adp_mtrl_styles.xml b/alertdialogpro-theme-material/res/values-v14/adp_mtrl_styles.xml index f5a9664..d3c8011 100644 --- a/alertdialogpro-theme-material/res/values-v14/adp_mtrl_styles.xml +++ b/alertdialogpro-theme-material/res/values-v14/adp_mtrl_styles.xml @@ -1,7 +1,7 @@ - + + + \ No newline at end of file diff --git a/alertdialogpro-theme-material/res/values-v21/adp_mtrl_styles.xml b/alertdialogpro-theme-material/res/values-v21/adp_mtrl_styles.xml index e8c7c20..033fd5f 100644 --- a/alertdialogpro-theme-material/res/values-v21/adp_mtrl_styles.xml +++ b/alertdialogpro-theme-material/res/values-v21/adp_mtrl_styles.xml @@ -1,20 +1,20 @@ - - + + - - - + \ No newline at end of file diff --git a/alertdialogpro-theme-material/res/values/adp_mtrl_styles.xml b/alertdialogpro-theme-material/res/values/adp_mtrl_styles.xml index 90a3819..d03bbb6 100644 --- a/alertdialogpro-theme-material/res/values/adp_mtrl_styles.xml +++ b/alertdialogpro-theme-material/res/values/adp_mtrl_styles.xml @@ -1,23 +1,7 @@ - - - - - - - - - - - + - + + + + + - - + + + + + + + + + + - + + diff --git a/alertdialogpro-theme-material/res/values/adp_mtrl_themes.xml b/alertdialogpro-theme-material/res/values/adp_mtrl_themes.xml index 6fcdbd3..58732d6 100644 --- a/alertdialogpro-theme-material/res/values/adp_mtrl_themes.xml +++ b/alertdialogpro-theme-material/res/values/adp_mtrl_themes.xml @@ -1,61 +1,55 @@ - - - - - -