├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── compiler.xml ├── dictionaries │ └── marco.xml ├── gradle.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── marcoscg │ │ └── headerdialogsample │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── marcoscg │ │ │ └── headerdialogsample │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-hdpi │ │ └── ic_action_action_info_outline.png │ │ ├── drawable-mdpi │ │ └── ic_action_action_info_outline.png │ │ ├── drawable-xhdpi │ │ └── ic_action_action_info_outline.png │ │ ├── drawable-xxhdpi │ │ └── ic_action_action_info_outline.png │ │ ├── drawable-xxxhdpi │ │ └── ic_action_action_info_outline.png │ │ ├── drawable │ │ └── ic_info_outline_black_48dp.png │ │ ├── layout │ │ ├── activity_main.xml │ │ └── custom.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── marcoscg │ └── headerdialogsample │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── marcoscg │ │ └── headerdialog │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── medium.ttf │ │ └── regular.ttf │ ├── java │ │ └── com │ │ │ └── marcoscg │ │ │ └── headerdialog │ │ │ ├── HeaderDialog.java │ │ │ └── widgets │ │ │ ├── ContentTextView.java │ │ │ ├── ContentTextViewJustified.java │ │ │ └── TitleTextView.java │ └── res │ │ ├── drawable │ │ └── top_shadow.xml │ │ ├── layout │ │ └── header_dialog_content.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── marcoscg │ └── headerdialog │ └── ExampleUnitTest.java ├── screenshots ├── 1.jpg └── 2.jpg └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoscgdev/HeaderDialog/e27aaa575f22b1ac0f2e9254add32fc2a8518244/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/dictionaries/marco.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 20 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Marcos Calvo García 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HeaderDialog  [![API](https://img.shields.io/badge/API-9%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=9) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-HeaderDialog-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5076) 2 | An android library to display a material-designed dialog with header. 3 | 4 | --- 5 | 6 | ## Releases: 7 | 8 | #### Current release: 1.0.6. 9 | 10 | You can see all the library releases [here](https://github.com/marcoscgdev/HeaderDialog/releases). 11 | 12 | --- 13 | 14 | ## Screenshots 15 | 16 | 17 | 18 | 19 | Get it on Google Play 20 | 21 | --- 22 | 23 | ## Features 24 | 25 | - Roboto font 26 | - LinkMovementMethod support 27 | - Justify text option 28 | - Icon, text and both as header 29 | - Custom header background color 30 | - Custom header text color 31 | - Custom header icon color 32 | - Custom header text gravity 33 | - Custom message text gravity 34 | - Show or hide header shadow 35 | - Multiline header title text option 36 | - Arabic text support 37 | - Custom view support (NEW) 38 | 39 | --- 40 | 41 | ## Usage: 42 | 43 | ### Adding the depencency 44 | 45 | Add this to your root *build.gradle* file: 46 | 47 | ``` 48 | allprojects { 49 | repositories { 50 | ... 51 | maven { url 'https://jitpack.io' } 52 | } 53 | } 54 | ``` 55 | 56 | Now add the dependency to your app build.gradle file: 57 | 58 | ``` 59 | implementation 'com.github.marcoscgdev:HeaderDialog:1.0.6' 60 | ``` 61 | 62 | ### Creating the dialog 63 | 64 | Here is a complete snippet of it usage: 65 | 66 | ```java 67 | new HeaderDialog(this) 68 | .setColor(getResources().getColor(R.color.colorAccent)) // Sets the header background color 69 | .setElevation(false) // Sets the header elevation, true by default 70 | .setIcon(getResources().getDrawable(R.drawable.ic_info_outline_black_48dp)) // Sets the dialog icon image 71 | .setTitle(getResources().getString(R.string.library_name)) // Sets the dialog title 72 | .setMessage("Lorem ipsum dolor sit amet...") // Sets the dialog message 73 | .justifyContent(true) // Justifies the message text, false by default 74 | .setTitleColor(Color.parseColor("#212121")) // Sets the header title text color 75 | .setIconColor(Color.parseColor("#212121")) // Sets the header icon color 76 | .setTitleGravity(Gravity.CENTER_HORIZONTAL) // Sets the header title text gravity 77 | .setMessageGravity(Gravity.CENTER_HORIZONTAL) // Sets the message text gravity 78 | .setTitleMultiline(false) // Multiline header title text option, true by default 79 | .setView(R.layout.custom); // Set custom view to the dialog (only possible via layout resource) 80 | .setPositiveButton("Ok", new DialogInterface.OnClickListener() { 81 | public void onClick(DialogInterface dialog, int which) { 82 | // Your action 83 | } 84 | }) 85 | .setNegativeButton("Close", null) 86 | .show(); 87 | ``` 88 | 89 | #### Important note: Do not enable the justified text if you are using html content! 90 | 91 | ### Accessing inflated custom view 92 | 93 | ```java 94 | HeaderDialog headerDialog = new HeaderDialog(this); 95 | ... 96 | headerDialog.show(); 97 | headerDialog.getInflatedView().findViewById(R.id.checkbox).setOnClickListener(new View.OnClickListener() { 98 | @Override 99 | public void onClick(View v) { 100 | Toast.makeText(MainActivity.this, "Checkbox clicked!", Toast.LENGTH_SHORT).show(); 101 | } 102 | }); 103 | ``` 104 | 105 | --- 106 | >See the *sample project* to clarify any queries you may have. 107 | 108 | --- 109 | 110 | ## License 111 | 112 | ``` 113 | The MIT License (MIT) 114 | 115 | Copyright (c) 2017 Marcos Calvo García 116 | 117 | Permission is hereby granted, free of charge, to any person obtaining a copy 118 | of this software and associated documentation files (the "Software"), to deal 119 | in the Software without restriction, including without limitation the rights 120 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 121 | copies of the Software, and to permit persons to whom the Software is 122 | furnished to do so, subject to the following conditions: 123 | 124 | The above copyright notice and this permission notice shall be included in all 125 | copies or substantial portions of the Software. 126 | 127 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 128 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 129 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 130 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 131 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 132 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 133 | SOFTWARE. 134 | ``` 135 | 136 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | defaultConfig { 6 | applicationId "com.marcoscg.headerdialogsample" 7 | minSdkVersion 14 8 | targetSdkVersion 27 9 | versionCode 106 10 | versionName "1.0.6" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'com.android.support:appcompat-v7:27.1.1' 24 | implementation project(':library') 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/marcoscg/headerdialogsample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.marcoscg.headerdialogsample; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.marcoscg.headerdialogsample", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/marcoscg/headerdialogsample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.marcoscg.headerdialogsample; 2 | 3 | import android.content.DialogInterface; 4 | import android.content.Intent; 5 | import android.graphics.Color; 6 | import android.net.Uri; 7 | import android.os.Build; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.os.Bundle; 10 | import android.text.Html; 11 | import android.view.Gravity; 12 | import android.view.Menu; 13 | import android.view.MenuItem; 14 | import android.view.View; 15 | import android.widget.CheckBox; 16 | import android.widget.CompoundButton; 17 | import android.widget.Toast; 18 | 19 | import com.marcoscg.headerdialog.HeaderDialog; 20 | 21 | public class MainActivity extends AppCompatActivity { 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_main); 27 | 28 | if (Build.VERSION.SDK_INT >= 21 && getSupportActionBar()!=null) 29 | getSupportActionBar().setElevation(0f); 30 | } 31 | 32 | public void showHeaderDialog(View v) { 33 | CheckBox hideIcon = (CheckBox) findViewById(R.id.hideIcon); 34 | CheckBox hideTitle = (CheckBox) findViewById(R.id.hideTitle); 35 | CheckBox justify = (CheckBox) findViewById(R.id.justify); 36 | 37 | HeaderDialog headerDialog = new HeaderDialog(this); 38 | headerDialog.setColor(getResources().getColor(R.color.colorAccent)); 39 | 40 | if (!hideIcon.isChecked()) 41 | headerDialog.setIcon(getResources().getDrawable(R.drawable.ic_info_outline_black_48dp)); 42 | 43 | if (!hideTitle.isChecked()) 44 | headerDialog.setTitle(getResources().getString(R.string.app_name)); 45 | 46 | headerDialog.setMessage(getResources().getString(R.string.lorem)); 47 | 48 | if (justify.isChecked()) 49 | headerDialog.justifyContent(true); 50 | 51 | headerDialog.setTitleColor(Color.parseColor("#212121")); 52 | headerDialog.setTitleGravity(Gravity.CENTER_HORIZONTAL); 53 | headerDialog.setView(R.layout.custom); 54 | headerDialog.setPositiveButton(android.R.string.ok, null); 55 | headerDialog.show(); 56 | 57 | ((CheckBox)headerDialog.getInflatedView().findViewById(R.id.checkbox)) 58 | .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 59 | @Override 60 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 61 | Toast.makeText(MainActivity.this, "Checkbox checked: " + isChecked, Toast.LENGTH_SHORT).show(); 62 | } 63 | }); 64 | } 65 | 66 | @Override 67 | public boolean onCreateOptionsMenu(Menu menu) { 68 | getMenuInflater().inflate(R.menu.menu_main, menu); 69 | return true; 70 | } 71 | 72 | @Override 73 | public boolean onOptionsItemSelected(MenuItem item) { 74 | int id = item.getItemId(); 75 | if (id == R.id.action_settings) { 76 | showAboutDialog(); 77 | return true; 78 | } 79 | return super.onOptionsItemSelected(item); 80 | } 81 | 82 | public void showAboutDialog() { 83 | String msg = getResources().getString(R.string.about_text); 84 | new HeaderDialog(this) 85 | .setColor(getResources().getColor(R.color.colorAccent)) 86 | .setIcon(getResources().getDrawable(R.mipmap.ic_launcher)) 87 | .setTitle(getResources().getString(R.string.library_name)) 88 | .setMessage(Html.fromHtml(msg)) 89 | .setElevation(true) 90 | .justifyContent(false) // Default false 91 | .setTitleColor(getResources().getColor(R.color.colorPrimary)) 92 | .setTitleGravity(Gravity.CENTER_HORIZONTAL) 93 | .setMessageGravity(Gravity.CENTER_HORIZONTAL) 94 | .setPositiveButton("Close", null) 95 | .setNeutralButton("View on GitHub", new DialogInterface.OnClickListener() { 96 | public void onClick(DialogInterface dialog, int which) { 97 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/marcoscgdev/HeaderDialog/"))); 98 | } 99 | }) 100 | .show(); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_action_action_info_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoscgdev/HeaderDialog/e27aaa575f22b1ac0f2e9254add32fc2a8518244/app/src/main/res/drawable-hdpi/ic_action_action_info_outline.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_action_action_info_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoscgdev/HeaderDialog/e27aaa575f22b1ac0f2e9254add32fc2a8518244/app/src/main/res/drawable-mdpi/ic_action_action_info_outline.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_action_info_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoscgdev/HeaderDialog/e27aaa575f22b1ac0f2e9254add32fc2a8518244/app/src/main/res/drawable-xhdpi/ic_action_action_info_outline.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_action_info_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoscgdev/HeaderDialog/e27aaa575f22b1ac0f2e9254add32fc2a8518244/app/src/main/res/drawable-xxhdpi/ic_action_action_info_outline.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_action_action_info_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoscgdev/HeaderDialog/e27aaa575f22b1ac0f2e9254add32fc2a8518244/app/src/main/res/drawable-xxxhdpi/ic_action_action_info_outline.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_info_outline_black_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoscgdev/HeaderDialog/e27aaa575f22b1ac0f2e9254add32fc2a8518244/app/src/main/res/drawable/ic_info_outline_black_48dp.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 |