{"id":13642247,"url":"https://github.com/yarolegovich/LovelyDialog","last_synced_at":"2025-04-20T16:31:11.761Z","repository":{"id":118737919,"uuid":"56489244","full_name":"yarolegovich/LovelyDialog","owner":"yarolegovich","description":"This library is a set of simple wrapper classes that are aimed to help you easily create fancy material dialogs.","archived":false,"fork":false,"pushed_at":"2022-10-08T14:25:43.000Z","size":2121,"stargazers_count":1061,"open_issues_count":29,"forks_count":190,"subscribers_count":34,"default_branch":"master","last_synced_at":"2024-11-07T16:04:57.804Z","etag":null,"topics":["android","android-library","android-ui","dialog","dialogs","fancy-material-dialogs","material-design","view"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yarolegovich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-04-18T08:12:04.000Z","updated_at":"2024-11-02T04:35:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"7db53c5d-edbe-4c1f-b988-2b5351847339","html_url":"https://github.com/yarolegovich/LovelyDialog","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarolegovich%2FLovelyDialog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarolegovich%2FLovelyDialog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarolegovich%2FLovelyDialog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarolegovich%2FLovelyDialog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yarolegovich","download_url":"https://codeload.github.com/yarolegovich/LovelyDialog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223832898,"owners_count":17210741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","android-ui","dialog","dialogs","fancy-material-dialogs","material-design","view"],"created_at":"2024-08-02T01:01:28.973Z","updated_at":"2025-04-20T16:31:11.754Z","avatar_url":"https://github.com/yarolegovich.png","language":"Java","funding_links":[],"categories":["对话框"],"sub_categories":[],"readme":"# LovelyDialog\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-LovelyDialog-green.svg?style=true)](https://android-arsenal.com/details/1/3452)\n\nThis library is a set of simple wrapper classes that are aimed to help you easily create fancy material dialogs.\n\n![Screenshots](https://raw.githubusercontent.com/yarolegovich/lovelydialog/master/art/lovelydialogs_framed.png)\n\n## Gradle \nAdd this into your dependencies block.\n```\ncompile 'com.yarolegovich:lovely-dialog:1.1.1'\n```\n\n## Wiki\n### General\nAs advised in Effective Java\n\u003e  Favor composition over inheritance.\n\nLovelyDialog doesn't subclass any Dialog related classes, it is just a lightweight extensible wrapper for Dialog and manipulations with custom view. If you would like to improve something - pull requests are appreciated.\n\nSample project that shows how to work with different dialogs and handle screen rotation is available under the [sample module](https://github.com/yarolegovich/LovelyDialog/tree/master/sample).\n### Dialog types\nEach dialog has colored top, icon, title and message + its own features. There are 6 types of dialogs available:\n* [LovelyStandardDialog](#lovelystandarddialog)\n* [LovelyInfoDialog](#lovelyinfodialog)\n* [LovelyTextInputDialog](#lovelytextinputdialog)\n* [LovelyChoiceDialog](#lovelychoicedialog)\n* [LovelyProgressDialog](#lovelyprogressdialog)\n* [LovelyCustomDialog](#lovelycustomdialog)\n\n### Access to inner View objects\n\nStarting from a version 1.1.0 of the library, you have an access to dialog's inner `View` objects via methods whose names are prefixed with `configure`. For example:\n\n```java\nlovelyDialog\n      .configureView(rootView -\u003e /* you can find any view here, view ids are prefixed with ld_ */)\n      .configureTitleView(title -\u003e title.setTextSize(customTextSize))\n      .configureMessageView(message -\u003e message.getPaint().setShader(customShader))\n      .show();\n```\nI advise not to overuse this feature. If you are doing it, think of creating a custom Dialog subclass. `LovelyTextInpuDialog` exposes its `EditText` via `configureEditText`.\n\n#### LovelyStandardDialog\nYou can set positive, negative and neutral button here. Listeners can be set individually for each button, one for all three or not set at all (onClick on any button dialog will be just dismissed).\n\n```java\nnew LovelyStandardDialog(this, LovelyStandardDialog.ButtonLayout.VERTICAL)\n      .setTopColorRes(R.color.indigo)\n      .setButtonsColorRes(R.color.darkDeepOrange)\n      .setIcon(R.drawable.ic_star_border_white_36dp)\n      .setTitle(R.string.rate_title) \n      .setMessage(R.string.rate_message)\n      .setPositiveButton(android.R.string.ok, new View.OnClickListener() {\n          @Override\n          public void onClick(View v) {\n              Toast.makeText(context, \"positive clicked\", Toast.LENGTH_SHORT).show();\n          }\n      }) \n      .setNegativeButton(android.R.string.no, null)\n      .show();\n\n```\n#### LovelyInfoDialog\nDialog for displaying information to the user, content is scrollable. There is an option to show Don't show again checkbox. If checked - dialog won't be called next time. This can be useful when showing some tutorials, for example. \n```java\nnew LovelyInfoDialog(this)\n      .setTopColorRes(R.color.darkBlueGrey)\n      .setIcon(R.drawable.ic_info_outline_white_36dp)\n      //This will add Don't show again checkbox to the dialog. You can pass any ID as argument\n      .setNotShowAgainOptionEnabled(0)\n      .setNotShowAgainOptionChecked(true)\n      .setTitle(R.string.info_title)\n      .setMessage(R.string.info_message)\n      .show();\n```\n#### LovelyChoiceDialog\nHere you can use either single choice or multi choice dialogs. In case of multi choice dialog - Confirm button will appear. You can pass items as array, List (.toString() will be used to display them as simple text items) or provide your custom adapter.\n\n##### Single choice\n```java\nArrayAdapter\u003cDonationOption\u003e adapter = new DonationAdapter(this, loadDonationOptions());\nnew LovelyChoiceDialog(this)\n      .setTopColorRes(R.color.darkGreen)\n      .setTitle(R.string.donate_title)\n      .setIcon(R.drawable.ic_local_atm_white_36dp)\n      .setMessage(R.string.donate_message)\n      .setItems(adapter, new LovelyChoiceDialog.OnItemSelectedListener\u003cDonationOption\u003e() {\n           @Override\n           public void onItemSelected(int position, DonationOption item) {\n               Toast.makeText(context, getString(R.string.you_donated, item.amount),Toast.LENGTH_SHORT).show();\n           }\n      })\n      .show();\n```\n##### Multi choice\n```java\nString[] items = getResources().getStringArray(R.array.food);\nnew LovelyChoiceDialog(this, R.style.CheckBoxTintTheme)\n      .setTopColorRes(R.color.darkRed)\n      .setTitle(R.string.order_food_title)\n      .setIcon(R.drawable.ic_food_white_36dp)\n      .setItemsMultiChoice(items, new LovelyChoiceDialog.OnItemsSelectedListener\u003cString\u003e() {\n          @Override\n          public void onItemsSelected(List\u003cInteger\u003e positions, List\u003cString\u003e items) {\n              Toast.makeText(MainActivity.this,\n                      getString(R.string.you_ordered, TextUtils.join(\"\\n\", items)),\n                      Toast.LENGTH_SHORT)\n                      .show();\n          }\n      })\n      .setConfirmButtonText(R.string.confirm)\n      .show();\n```\n#### LovelyTextInputDialog\nDialog with EditText and Confirm button. You can set TextFilter object to specify acceptable input. \n```java\nnew LovelyTextInputDialog(this, R.style.EditTextTintTheme)\n      .setTopColorRes(R.color.darkDeepOrange)\n      .setTitle(R.string.text_input_title)\n      .setMessage(R.string.text_input_message)\n      .setIcon(R.drawable.ic_assignment_white_36dp) \n      .setInputFilter(R.string.text_input_error_message, new LovelyTextInputDialog.TextFilter() {\n          @Override\n          public boolean check(String text) {\n              return text.matches(\"\\\\w+\");\n          }\n      })\n      .setConfirmButton(android.R.string.ok, new LovelyTextInputDialog.OnTextInputConfirmListener() {\n           @Override\n           public void onTextInputConfirmed(String text) {\n              Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show();\n           }\n      }) \n      .show();\n```\n#### LovelyProgressDialog\nDialog with standard Android ProgressBar. Not cancelable by default.\n```java\nnew LovelyProgressDialog(this)\n      .setIcon(R.drawable.ic_cast_connected_white_36dp)\n      .setTitle(R.string.connecting_to_server)\n      .setTopColorRes(R.color.teal)\n      .show();\n```\n#### LovelyCustomDialog\nHere you can pass your own view to be displayed. Title, message, color header and icon will still be available for use. You can provide configurators, click listeners and instance state save handlers.\n```java\nnew LovelyCustomDialog(this)\n      .setView(R.layout.item_donate_option)\n      .setTopColorRes(R.color.darkDeepOrange)\n      .setTitle(R.string.text_input_title)\n      .setMessage(R.string.text_input_message)\n      .setIcon(R.drawable.ic_assignment_white_36dp)\n      .configureView(/* ... */)\n      .setListener(R.id.ld_btn_yes, /* ... */)\n      .setInstanceStateManager(/* ... */)\n      .show();\n```\n### Configuration changes\nThere is a class LovelySaveStateHandler that helps you to persist information about which dialog was shown (if any) between configuration changes. \nEach dialog (except LovelyCustomDialog) knows how to save and restore its state. \nRefer to [sample project](https://github.com/yarolegovich/LovelyDialog/blob/master/sample/src/main/java/com/yarolegovich/sample/MainActivity.java) for examples of how to deal with configuration changes.\n### Tinting controls\nIf you want CheckBoxes, EditTexts etc. to be of different color - what you need is to define theme in xml\n```xml\n\u003cstyle name=\"TintTheme\" parent=\"Theme.AppCompat.Light.Dialog.Alert\"\u003e\n      \u003citem name=\"colorAccent\"\u003e@color/colorToTintWith\u003c/item\u003e\n\u003c/style\u003e\n```\nand pass it as a second argument to dialog's constructor\n```java\nnew LovelyTextInputDialog(this, R.style.TintTheme)\n```\n### Standard dialogs compatibility\nIf you don't want to rewrite your\n```java\nDialog.OnClickListener\n```\nimplementations, you can simply use\n```java\nLovalyDialogCompat.wrap(yourImplementation)\n```\nto pass it to one of the\n```java\n.setPositiveButton(...)\n.setNegativeButton(...)\n```\nor the like.\n### License\n```\nCopyright 2016 Yaroslav Shevchuk\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarolegovich%2FLovelyDialog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyarolegovich%2FLovelyDialog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarolegovich%2FLovelyDialog/lists"}